mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-03-17 21:31:45 +01:00
* 4559 fsck on release * fsck on release * fsck after expand * remove toc.sh * #4861 force locale on release
This commit is contained in:
parent
d0f97a4ccb
commit
7989b4c54d
@ -67,23 +67,13 @@ if [ "${action}" == "fsexpand" ]; then
|
||||
if [ -x ${resizeRaspbian} ]; then
|
||||
echo "# RUNNING EXPAND RASPBERRYPI: ${resizeRaspbian}"
|
||||
sudo $resizeRaspbian --expand-rootfs 1>&2
|
||||
sudo touch /forcefsck
|
||||
echo "# DONE - please reboot"
|
||||
else
|
||||
echo "# FAIL to execute on ${baseimage}: ${resizeRaspbian}"
|
||||
echo "err='expand failed'"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "${baseimage}" = "armbian" ]; then
|
||||
resizeArmbian="/usr/lib/armbian/armbian-resize-filesystem"
|
||||
if [ -x ${resizeArmbian} ]; then
|
||||
echo "# RUNNING EXPAND ARMBIAN: ${resizeArmbian}"
|
||||
sudo $resizeArmbian start 1>&2
|
||||
echo "# DONE - please reboot"
|
||||
else
|
||||
echo "# FAIL to execute on ${baseimage}: ${resizeArmbian}"
|
||||
echo "err='expand failed'"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "#FAIL no implementation for: ${baseimage}"
|
||||
echo "err='missing implementation'"
|
||||
|
@ -98,6 +98,25 @@ sudo systemctl disable ssh
|
||||
sudo rm /etc/ssh/ssh_host_*
|
||||
echo "OK"
|
||||
|
||||
# force locale - see #4861
|
||||
# next major release should make sure to be set during sd build card
|
||||
echo
|
||||
echo "Forcing locales ..."
|
||||
sudo sed -i '/^en_US.UTF-8/s/^#//' /etc/locale.gen
|
||||
sudo sed -i '/^en_GB.UTF-8/s/^/#/' /etc/locale.gen
|
||||
sudo locale-gen
|
||||
echo -e "LANG=en_US.UTF-8\nLANGUAGE=en_US.UTF-8\nLC_ALL=en_US.UTF-8" | sudo tee /etc/default/locale > /dev/null
|
||||
|
||||
# make sure file system is clean and ready for release
|
||||
echo
|
||||
echo "fsck on first boot ..."
|
||||
sudo touch /forcefsck
|
||||
if [ -e /dev/mmcblk0 ]; then
|
||||
echo "fsck on /dev/mmcblk0 ..."
|
||||
sudo umount /dev/mmcblk0p1
|
||||
sudo fsck -fy /dev/mmcblk0p1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Will shutdown now."
|
||||
echo "Wait until Raspberry LEDs show no activity anymore."
|
||||
|
@ -1,105 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Just run this script once after a fresh sd card build
|
||||
# to prepare the image for release as a downloadable sd card image
|
||||
# call with parameter `-quick` to skip skip os update
|
||||
|
||||
# determine correct raspberrypi boot drive path (that easy to access when sd card is insert into laptop)
|
||||
raspi_bootdir=""
|
||||
if [ -d /boot/firmware ]; then
|
||||
raspi_bootdir="/boot/firmware"
|
||||
elif [ -d /boot ]; then
|
||||
raspi_bootdir="/boot"
|
||||
fi
|
||||
echo "# raspi_bootdir(${raspi_bootdir})"
|
||||
|
||||
# write release info to to version file
|
||||
echo "writing codeRelease commit ro version file:"
|
||||
releaseCommit=$(git -C /home/admin/raspiblitz rev-parse --short HEAD)
|
||||
sed -i 's/^codeRelease=".*"/codeRelease="${releaseCommit}"/' /home/admin/_version.info
|
||||
cat /home/admin/_version.info
|
||||
echo
|
||||
|
||||
# stop background services
|
||||
sudo systemctl stop background.service
|
||||
sudo systemctl stop background.scan.service
|
||||
|
||||
# remove stop flag (if exists)
|
||||
echo "deleting stop flag .."
|
||||
sudo rm ${raspi_bootdir}/stop 2>/dev/null
|
||||
|
||||
# cleaning logs
|
||||
echo "deleting raspiblitz & system logs .."
|
||||
sudo rm -rf /var/log/journal/* 2>/dev/null
|
||||
sudo rm /var/log/redis/* 2>/dev/null
|
||||
sudo rm /var/log/private/* 2>/dev/null
|
||||
sudo rm /var/log/nginx/* 2>/dev/null
|
||||
sudo rm /home/admin/*.log 2>/dev/null
|
||||
logger -p info "****** RASPIBLITZ RELEASE ******"
|
||||
echo "OK"
|
||||
|
||||
# clean raspiblitz.info toward the values set by sd card build script
|
||||
echo "cleaning raspiblitz.info"
|
||||
source /home/admin/raspiblitz.info
|
||||
echo "baseimage=${baseimage}" > /home/admin/raspiblitz.info
|
||||
echo "cpu=${cpu}" >> /home/admin/raspiblitz.info
|
||||
echo "blitzapi=${blitzapi}" >> /home/admin/raspiblitz.info
|
||||
echo "displayClass=${displayClass}" >> /home/admin/raspiblitz.info
|
||||
|
||||
# https://github.com/rootzoll/raspiblitz/issues/1371
|
||||
echo
|
||||
echo "deactivate local WIFI ..."
|
||||
sudo nmcli radio wifi off
|
||||
echo "OK"
|
||||
|
||||
# make sure that every install runs API with own secret
|
||||
# https://github.com/raspiblitz/raspiblitz/issues/4469
|
||||
echo
|
||||
echo "deleting old API conf ..."
|
||||
sudo rm /home/blitzapi/blitz_api/.env 2>/dev/null
|
||||
REDIS_ENABLED=$(sudo systemctl is-enabled redis 2>/dev/null | grep -c enabled)
|
||||
if [ ${REDIS_ENABLED} -gt 0 ]; then
|
||||
echo "disable redis for initial start ..."
|
||||
sudo systemctl stop redis 2>/dev/null
|
||||
sudo systemctl disable redis 2>/dev/null
|
||||
fi
|
||||
echo "deleting redis data (if still there) ..."
|
||||
sudo rm /var/lib/redis/dump.rdb 2>/dev/null
|
||||
echo "OK"
|
||||
|
||||
# https://github.com/rootzoll/raspiblitz/issues/1068#issuecomment-599267503
|
||||
echo
|
||||
echo "reset DNS confs ..."
|
||||
echo -e "nameserver 1.1.1.1\nnameserver 84.200.69.80" | sudo tee /etc/resolv.conf > /dev/null
|
||||
echo "OK"
|
||||
|
||||
# make sure Tor respo signing keys are uptodate #4648
|
||||
wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/torproject.gpg >/dev/null
|
||||
|
||||
# update system (only security updates with minimal risk of breaking changes)
|
||||
if [ "$1" != "-quick" ]; then
|
||||
echo
|
||||
echo "update OS ..."
|
||||
sudo apt-get update -y
|
||||
sudo apt-get upgrade -o Dir::Etc::SourceList=/etc/apt/sources.list.d/security.list -y
|
||||
sudo apt-get upgrade openssh-server -y
|
||||
sudo dpkg --configure -a
|
||||
else
|
||||
echo
|
||||
echo "skipping OS update ..."
|
||||
fi
|
||||
|
||||
# SSH Pubkeys (make unique for every sd card image install)
|
||||
echo
|
||||
echo "deleting SSH Pub keys ..."
|
||||
echo "keys will get recreated and sshd reactivated on fresh bootup, by _bootstrap.sh service"
|
||||
sudo systemctl stop ssh
|
||||
sudo systemctl disable ssh
|
||||
sudo rm /etc/ssh/ssh_host_*
|
||||
echo "OK"
|
||||
|
||||
echo
|
||||
echo "Will shutdown now."
|
||||
echo "Wait until Raspberry LEDs show no activity anymore."
|
||||
echo "Then remove SD card and make an release image from it."
|
||||
sudo shutdown now
|
70
toc.sh
70
toc.sh
@ -1,70 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
## Updated version maintained on https://github.com/nyxnor/scripts/blob/master/toc.sh
|
||||
|
||||
## Produces Table of Contents (ToC) for simple markdown files
|
||||
## Requirement: header is set by hashtag '#'
|
||||
## $1 = FILE.md
|
||||
|
||||
red="\033[31m"
|
||||
nocolor="\033[0m"
|
||||
|
||||
error_msg(){ printf %s"${red}ERROR: ${1}\n${nocolor}" >&2; exit 1; }
|
||||
|
||||
test -f "${1}" || error_msg "file '${1}' doesn't exist"
|
||||
|
||||
trap 'rm -f toc.tmp' EXIT INT
|
||||
|
||||
line_count=0
|
||||
while IFS="$(printf '\n')" read -r line; do
|
||||
line_count=$((line_count+1))
|
||||
## extract code blocks
|
||||
code="${code:-0}"
|
||||
[ "${code}" -eq 0 ] && printf '%s\n' "${line_count}:${line}" | grep "^${line_count}:.*# "
|
||||
case "${line}" in
|
||||
*\`\`\`*)
|
||||
case "${code}" in
|
||||
1) code=0;;
|
||||
0|*) code=1;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done < "${1}" > toc.tmp
|
||||
|
||||
|
||||
while IFS="$(printf '\n')" read -r line; do
|
||||
## get line number
|
||||
line_number="$(printf '%s\n' "${line}" | cut -d ":" -f1)"
|
||||
## remove hashtag from line to be compared later if it is repeated
|
||||
line_clean="$(printf '%s\n' "${line}" | sed "s/.*\# //")"
|
||||
## save header to cache to check later if it was already printed
|
||||
# shellcheck disable=SC2030
|
||||
line_cache="$(printf '%s\n%s\n' "${line_cache}" "${line}")"
|
||||
## check if header was already printed before and if positive, save all repeated headers
|
||||
## if positive, insert link index
|
||||
line_repeated="$(printf '%s\n' "${line_cache}" | grep -c -- ".*# ${line_clean}$")"
|
||||
line_repeated_index=""
|
||||
## first line does not have '-n', just the first repeated line (second occurence), starting with '-1'. So we consider the occurrence-1.
|
||||
[ "${line_repeated}" -ge 2 ] && line_repeated_index="-$((line_repeated-1))"
|
||||
## if it is the second time line has repeated, save first and second occurrence
|
||||
if [ "${line_repeated}" -eq 2 ]; then
|
||||
line_first_occurrence="$(printf '%s\n' "${line_cache}" | grep -- ".*# ${line_clean}$" | head -n 1)"
|
||||
line_repeated_cache="$(printf '%s\n%s\n' "${line_first_occurrence}" "${line}")"
|
||||
## if it is the third or greater time line has repeated, save lines from before (1st and 2nd occurrence) plus add current lines
|
||||
elif [ "${line_repeated}" -gt 2 ]; then
|
||||
line_repeated_cache="$(printf '%s\n%s\n' "${line_repeated_cache}" "${line}")"
|
||||
fi
|
||||
## clean header that have link reference
|
||||
line_md="$(printf '%s\n' "${line}" | sed "s/${line_number}://;s|](.*||;s|\[||;s/\]//g")"
|
||||
## set header indentation
|
||||
line_md="$(printf '%s\n' "${line_md}" | sed "s|######| -|;s|#####| -|;s|####| -|;s|###| -|;s|##| -|;s|#|-|")"
|
||||
## set link content
|
||||
line_content="$(printf '%s\n' "${line_md}" | sed "s/.*- /#/;s| |-|g;s|'||g;s|]||g;s/|/-/g" | tr "[:upper:]" "[:lower:]" | tr -cd "[:alnum:]-_" | tr -d ".")"
|
||||
## set link reference
|
||||
line_md="$(printf '%s\n' "${line_md}" | sed "s|- |- [|;s|$|](#${line_content}${line_repeated_index})|")"
|
||||
## print header
|
||||
printf '%s\n' "${line_md}"
|
||||
done < toc.tmp
|
||||
|
||||
[ -n "${line_repeated_cache}" ] &&
|
||||
printf %s"\n\nWARN: Some headers are repeated, the hiperlinks are correctly indexed. If you think this is an error, review these lines:headers:\n${line_repeated_cache}\n"
|
Loading…
x
Reference in New Issue
Block a user