From 49af2f186e023eb35520aaca326821ef5462ae96 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 1 Sep 2020 21:34:16 +0100 Subject: [PATCH 01/42] iiab-upgrade --- iiab-upgrade | 408 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 408 insertions(+) create mode 100755 iiab-upgrade diff --git a/iiab-upgrade b/iiab-upgrade new file mode 100755 index 00000000..35f163f0 --- /dev/null +++ b/iiab-upgrade @@ -0,0 +1,408 @@ +#!/bin/bash +# jvonau +set -e # Exit on error (avoids snowballing) +export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions +SCRIPT=iiab-upgrade +RELEASE=1 +BASEDIR=/opt/iiab +CONFDIR=/etc/iiab +FLAGDIR=$CONFDIR/install-flags +APT_PATH=/usr/bin/apt # Avoids problematic /usr/local/bin/apt on Linux Mint +REINSTALL="" +INTERACTIVE=0 +UPDATE=0 +MIN_RPI_KERN=1336 +SELFUPDATE_SCRIPT="/tmp/.updateScript.sh" +# scrape the command line +if [ "$1" = "--non-interactive" ]; then + shift 1 + INTERACTIVE=0 +fi + +if [ "$1" = "--upgrade" ]; then + shift 1 + rm $FLAGS/iiab*complete || true + UPDATE=1 + REINSTALL="--reinstall" +fi + +if [ "$1" = "--reinstall" ]; then + rm $FLAGS/iiab*complete || true + REINSTALL="--reinstall" +fi + +# cleanup +#if [ -f $SELFUPDATE_SCRIPT ]; then +# rm $SELFUPDATE_SCRIPT +#fi + +# Subroutines for upgrade logic +check_branch(){ + git -C $BASEDIR/iiab branch | grep \* | grep release-7 | wc -l +} + +function use_master(){ + cd $BASEDIR + if [ -d iiab ]; then + cd iiab + git checkout -b master &> /dev/null || true # covers older curls of release-7.0 + git config branch.master.remote origin || true # covers older curls of release-7.0 + git config branch.master.merge refs/heads/master || true # covers older curls of release-7.0 + fi + cd $BASEDIR + if [ -d iiab-admin-console ]; then + cd iiab-admin-console + git checkout -b master &> /dev/null || true # covers older curls of release-7.0 + git config branch.master.remote origin || true # covers older curls of release-7.0 + git config branch.master.merge refs/heads/master || true # covers older curls of release-7.0 + fi +} + +function update_master(){ + cd $BASEDIR + if [ -d iiab ]; then + cd iiab + echo -e "\nUpdating iiab" + git checkout master + git pull + fi + cd $BASEDIR + if [ -d iiab-admin-console ]; then + echo -e "\nUpdating iiab-admin-console" + cd iiab-admin-console + git checkout master + git pull + fi +} + +function update_self() { + echo " *** Performing self-update" + cd $BASEDIR + if [ -d iiab-factory ]; then + echo -e "\nUpdating iiab-factory" + cd iiab-factory + git checkout master + git pull + fi + + NEW_VERSION=$(grep RELEASE /opt/iiab/iiab-factory/$SCRIPT | awk -F = '{print $2}' | head -n 1) + if [ $NEW_VERSION -gt $RELEASE ]; then + cp /opt/iiab/iiab-factory/$SCRIPT /usr/sbin/$SCRIPT + echo "Latest $SCRIPT now installed" + cat > "$SELFUPDATE_SCRIPT" << EOF + #!/bin/bash + echo " *** Relaunching $SCRIPT after update" +# exec env /bin/bash /usr/sbin/$SCRIPT + exec /usr/sbin/$SCRIPT +EOF + exec /bin/bash $SELFUPDATE_SCRIPT + else + echo " Latest $SCRIPT is already installed" + fi +} + +# start exec here +update_self + +if [ `check_branch` -gt 0 ]; then + echo -e "\nFound release-7.X branch would you like (re)install using the latest master?" + echo -e "[Y/n]\n n default 5 second timeout" + ans="n" +# if [ $INTERACTIVE == 1 ]; then +# read -t 5 ans < /dev/tty +# fi + read -t 5 ans < /dev/tty + if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then + UPDATE=1 + else + echo "remaning on release-7.X branch updating" + cd $BASEDIR/iiab + git pull + fi +fi + +# A. Subroutine for B. and D. Returns true (0) if username ($1) exists with password ($2) +check_user_pwd() { + # $meth (hashing method) is typically '6' which implies 5000 rounds + # of SHA-512 per /etc/login.defs -> /etc/pam.d/common-password + meth=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f2) + salt=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f3) + hash=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f4) + [ $(python3 -c "import crypt; print(crypt.crypt('$2', '\$$meth\$$salt'))") == "\$$meth\$$salt\$$hash" ] +} + +# B. Ask for password change if pi/raspberry default remains +if check_user_pwd "pi" "raspberry"; then + echo -e "\n\nRaspberry Pi's are COMPROMISED often if the default password is not changed!\n" + echo -n "What password do you want for GNU/Linux user 'pi' ? " + read -t 5 ans < /dev/tty # Whines but doesn't change password if [Enter] + echo pi:"$ans" | chpasswd || true # Overrides 'set -e' +fi + +# C. Create user 'iiab-admin' as nec, with default password +if ! id -u iiab-admin > /dev/null 2> /dev/null; then + useradd iiab-admin + echo iiab-admin:g0adm1n | chpasswd +fi + +# D. Ask for password change if iiab-admin/g0adm1n default remains +if check_user_pwd "iiab-admin" "g0adm1n"; then + echo -e "\n\nUser 'iiab-admin' retains default password 'g0adm1n' per http://FAQ.IIAB.IO\n" + + echo -e "This is for login to Internet-in-a-Box's Admin Console (http://box.lan/admin)\n" + if [ $INTERACTIVE == 1 ]; then + echo -n "What password do you want for GNU/Linux user 'iiab-admin' ? " + echo -n "press [Enter] for no change" + read -t 15 ans < /dev/tty # Whines but doesn't change password if [Enter] + echo iiab-admin:"$ans" | chpasswd || true # Overrides 'set -e' + fi +fi + +if [ -f $FLAGDIR/iiab-complete ]; then + echo -e "\n\nIIAB INSTALLATION (/usr/sbin/iiab) IS ALREADY COMPLETE -- per existence of:" + echo -e "$FLAGDIR/iiab-complete -- nothing to do.\n" + exit 0 +fi + +mkdir -p $FLAGDIR +# E. Position & customize $CONFDIR/local_vars.yml +cd $CONFDIR +if [ -f local_vars.yml ]; then + + # FUTURE: Test if their local_vars.yml is sufficiently version-compatible ! + + echo -e "\n\n EXISTING $CONFDIR/local_vars.yml is being used to install Internet-in-a-Box\n" + + echo -e " ๐Ÿš‚ ๐Ÿšƒ ๐Ÿš„ ๐Ÿš… ๐Ÿš† ๐Ÿš‡ ๐Ÿšˆ ๐Ÿš‰ ๐ŸšŠ ๐Ÿš‹ ๐ŸšŒ ๐Ÿš ๐ŸšŽ ๐Ÿš ๐Ÿš ๐Ÿš‘ ๐Ÿš’ ๐Ÿšš ๐Ÿš› ๐Ÿšœ ๐Ÿšž ๐ŸšŸ ๐Ÿš  ๐Ÿšก ๐Ÿšฒ\n" + + echo -e " Google 'local_vars.yml' to learn more!" +else + echo -e "\n\nInstalling Internet-in-a-Box requires $CONFDIR/local_vars.yml" + echo -e "Do you want (1) ๐Ÿšต MIN-sized (2) ๐Ÿšข๐Ÿšฃ MEDIUM-sized or (3) ๐Ÿš‚๐Ÿšƒ๐Ÿšƒ BIG-sized?\n" + + echo -e "These take about 1, 2 or 3 hours on an older Raspberry Pi 3 or 3 B+, depending" + echo -e "on Internet speed, CPU speed/temperature and microSD card/disk speed. Please" + echo -e "use a Raspberry Pi 4 or x86_64 to install in about an hour or less !\n" + + echo -e 'See "What can I do with E-books and Internet-in-a-Box?" and "What services' + echo -e '(IIAB apps) are suggested during installation?" within http://FAQ.IIAB.IO\n' + + echo -n "Please type 1, 2 or 3 then press [ENTER]: " + local_vars_size="" + if [ "$INTERACTIVE" == 1 ]; then + read local_vars_size < /dev/tty + fi + echo + case $local_vars_size in + 1) + cp $BASEDIR/iiab/vars/local_vars_min.yml local_vars.yml + ;; + 3) + cp $BASEDIR/iiab/vars/local_vars_big.yml local_vars.yml + ;; + *) + cp $BASEDIR/iiab/vars/local_vars_medium.yml local_vars.yml + ;; + esac + + echo -en "\nEdit /etc/iiab/local_vars.yml to customize your Internet-in-a-Box? [Y/n] " + ans="n" + if [ "$INTERACTIVE" == 1 ]; then + read -t 5 ans < /dev/tty + fi + if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then + exit 0 +# echo -en "ctrl x to save and exit" +# sleep 2 +# nano /etc/iiab/local_vars.yml + fi +fi + +if [ $UPDATE == 1 ]; then + use_master + update_master +fi + +# F. Mandate OS SECURITY/UPDATES if 'apt update' has any (IF SO REBOOT) +# Educate implementer while waiting for 'apt update' +echo -e "\n\n โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆ โ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆ RUN 'sudo iiab' IF THIS INSTALL SCRIPT EVER FAILS, TO TRY TO CONTINUE! โ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆ โ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" +echo -e "\n\n'apt update' is checking for OS updates...\n" +#echo -e "2019-07-11 TEMP WORKAROUND FOR RASPBIAN BUSTER'S testing->stable apt GLITCH...\nDetails @ https://github.com/iiab/iiab/issues/1856\n" +#apt -y update || true # Overrides 'set -e' +#echo -e "\nNOW THE REAL 'apt update' WILL RUN...\n" +$APT_PATH -qq update > /tmp/apt.stdout 2> /tmp/apt.stderr || true # Overrides 'set -e' +if [ $(wc -c < /tmp/apt.stderr) -gt 82 ]; then # apt.stderr typically contains exactly 82 characters when there are no errors, no matter the primary locale, i.e. 3-line file "\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n\n" ...OR... in other cases more than 82, e.g. many lines of errors when apt is busy/locked/offline/etc + echo -e "'apt update' FAILED. VERIFY YOU'RE ONLINE and resolve all errors below:\n" + cat /tmp/apt.stderr + exit 1 +elif grep -q 'apt list --upgradable' /tmp/apt.stdout; then # apt.stdout typically contains {"All packages are up to date.\n" [even if primary locale is French & Hindi!], "Todos los paquetes estรกn actualizados.\n", "ๆ‰€ๆœ‰่ฝฏไปถๅŒ…ๅ‡ไธบๆœ€ๆ–ฐใ€‚\n"} ...OR... {"5 packages can be upgraded. Run 'apt list --upgradable' to see them.\n" [even if primary locale is French & Hindi!], "Se puede actualizar 1 paquete. Ejecute ยซapt list --upgradableยป para verlo.\n", "ๆœ‰ 1 ไธช่ฝฏไปถๅŒ…ๅฏไปฅๅ‡็บงใ€‚่ฏทๆ‰ง่กŒ โ€˜apt list --upgradableโ€™ ๆฅๆŸฅ็œ‹ๅฎƒไปฌใ€‚\n"} + cat /tmp/apt.stdout + if [ "$INTERACTIVE" == 1 ]; then + echo -e "\nYour OS will now be upgraded...this takes time. THEN IT WILL AUTO-REBOOT.\n" + echo -n "Hit [ENTER] to confirm you'll RUN 'sudo iiab' AFTER IT REBOOTS: " + read ans < /dev/tty + echo + $APT_PATH -y dist-upgrade + reboot + exit 0 # Nec to avoid both output lines below (that confuse implementers!) + else + $APT_PATH -y dist-upgrade + fi +fi +cat /tmp/apt.stdout # "All packages are up to date.\n" + +if [ $INTERACTIVE == 1 ]; then + echo -ne "\nHit [ENTER] to confirm you'll TRY TO RERUN 'sudo iiab' IF THERE IS A PROBLEM: " + read -t 5 ans < /dev/tty +fi + +# Subroutine compares software version numbers. Generates rare false positives +# like "1.0 > 1" and "2.4.0 > 2.4". Avoid risks by structuring conditionals w/ +# a consistent # of decimal points e.g. "if version_gt w.x.y.z a.b.c.d; then" +version_gt() { [ "$(printf '%s\n' "$@" | sort -V | head -1)" != "$1" ]; } + +# Verify that Raspbian is running a recent enough kernel. As Raspbian +# kernel 1333 has wifi issues https://github.com/iiab/iiab/issues/2497. +CURR_KERN=`uname -v | awk '{print $1}' | sed -e s'/#//'` +echo "Found Kernel ""$CURR_KERN" +if [ -f /etc/rpi-issue ] && version_gt $MIN_RPI_KERN $CURR_KERN; then + echo -e "\033[31;5mWARNING: Kernel ""$MIN_RPI_KERN"" or higher required with Raspbian.\033[0m" +# echo -e "\033[31;5mPLEASE RUN 'apt update' then 'apt install raspberrypi-kernel' then reboot.\033[0m" + echo -e "\033[31;5mTHEN IF NEC run 'rpi-update' to install a more recent kernel post-install, then reboot.\033[0m" + echo -e "'enter' to continue" + if [ $INTERACTIVE == 1 ]; then + read -t 10 ans < /dev/tty + fi +fi + + +######################### INTERACTIVE STUFF IS ABOVE ######################### + +# G. If RPi, lower reserve disk space from ~5% to 1% +#if [ -f /proc/device-tree/model ] && grep -qi raspberry /proc/device-tree/model; then +if [ -e /dev/mmcblk0p2 ]; then + echo -e "\n\nFound microSD card /dev/mmcblk0p2: Lower its reserve disk space from ~5% to 1%\n" + tune2fs -m 1 /dev/mmcblk0p2 +fi + +# I. Install Ansible + 2 IIAB repos +echo -e "\n\nINSTALL ANSIBLE + CORE IIAB SOFTWARE + ADMIN CONSOLE / CONTENT PACK MENUS...\n" + +echo -e "Install Ansible..." +$BASEDIR/iiab/scripts/ansible + +echo -e "\nโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”" +echo -e "โ”‚ โ”‚" +echo -e "โ”‚ NOW INSTALL IIAB SOFTWARE! If glitches arise (connectivity or otherwise) โ”‚" +echo -e "โ”‚ โ”‚" +echo -e "โ”‚ PLEASE TRY TO CONTINUE BY RE-RUNNING PARENT SCRIPT 'sudo iiab' -- or run โ”‚" +echo -e "โ”‚ โ”‚" +echo -e "โ”‚ child script ./iiab-install -- both avoid repeating any of the 9 stages. โ”‚" +echo -e "โ”‚ โ”‚" +echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" +cd $BASEDIR/iiab/ +./iiab-install $REINSTALL + +echo -e "Install Admin Console... (also runs iiab-get-kiwix-cat to d/l Kiwix catalog, and installs Dynamic Menuing for /library/www/html/home/index.html)\n" +if [ ! -f $FLAGDIR/iiab-admin-console-complete ] || [ $UPDATE == 1 ]; then + cd $BASEDIR/iiab-admin-console + ./install + touch $FLAGDIR/iiab-admin-console-complete +else + echo -e "ADMIN CONSOLE INSTALLATION IS ALREADY COMPLETE -- per existence of:" + echo -e "$FLAGDIR/iiab-admin-console-complete\n" +fi + +# J. KA Lite prep +if [ -d /library/ka-lite ]; then + echo -e "\n\nKA LITE REQUIRES 2 THINGS...\n" + + echo -e "Register with KA Lite - just the anonymous registration...\n" + # /usr/bin/kalite venv wrapper invokes 'export KALITE_HOME=/library/ka-lite' + if [ ! -f $FLAGDIR/kalite-zone-complete ]; then + echo -e "Now running 'kalite manage generate_zone' ...\n" + kalite manage generate_zone || true # Overrides 'set -e' + touch $FLAGDIR/kalite-zone-complete + else + echo -e "'kalite manage generate_zone' IS ALREADY COMPLETE -- per existence of:" + echo -e "$FLAGDIR/kalite-zone-complete\n" + fi + + echo -e "\nInstall KA Lite's mandatory 0.9 GB English Pack... (en.zip)\n" + if [ ! -f $FLAGDIR/kalite-en.zip-complete ]; then + #echo -e 'Now retrieving it...\n' + cd /tmp + if [ -f en.zip ]; then + if [ $(wc -c < en.zip) -ne 929916955 ]; then + echo -e "\nERROR: /tmp/en.zip must be 929,916,955 bytes to proceed.\n" >&2 + exit 1 + else + echo -e "\nUsing existing /tmp/en.zip whose 929,916,955 byte size is correct!\n" + fi + else + wget http://pantry.learningequality.org/downloads/ka-lite/0.17/content/contentpacks/en.zip + fi + echo -e 'Now installing /tmp/en.zip into /library/ka-lite/content/*\n' + kalite manage retrievecontentpack local en en.zip + touch $FLAGDIR/kalite-en.zip-complete + else + echo -e 'kalite zip already done' + fi +fi +# WARNING: /tmp/en.zip (and all stuff in /tmp) is auto-deleted during reboots +# NEW WAY ABOVE - since 2018-07-03 - installs KA Lite's mandatory English Pack +# +# kalite manage retrievecontentpack download en +# OLD WAY ABOVE - fails w/ sev ISPs per https://github.com/iiab/iiab/issues/871 + +# K. Start BitTorrent downloads, e.g. if $CONFDIR/local_vars.yml requested any +if (systemctl -q is-active transmission-daemon) then + echo -e "\n\nSTARTING BITTORRENT DOWNLOAD(S) for KA Lite...Please Monitor: http://box:9091\n" + transmission-remote -n Admin:changeme -t all --start +fi + +touch $FLAGDIR/iiab-complete + +# L. Educate Implementers prior to rebooting! +echo -e "\n\n โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”" +echo -e " โ”‚ โ”‚" +echo -e " โ”‚ INTERNET-IN-A-BOX (IIAB) SOFTWARE INSTALL IS COMPLETE โ”‚" +echo -e " โ”‚ โ”‚" +echo -e " โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜\n" + +echo -e "(1A) A couple minutes after you reboot (below) try to connect any laptop to" +echo -e 'Wi-Fi hotspot "Internet in a Box". If this works, verify that you can browse' +echo -e "to http://box or http://box.lan or http://172.18.96.1\n" + +echo -e "(1B) IF THOSE 3 DON'T WORK, try http://box.local from any device connected to" +echo -e "your usual network. Or try http://localhost from your IIAB itself!\n" + +echo -e "(1C) IF ALL 5 ABOVE DON'T WORK, ask the person who set up the network/router" +echo -e "in your building for the IP address of your IIAB, so you can browse to it" +echo -e "using (something like) http://192.168.0.100\n" + +echo -e '(2) ADD CONTENT using http://box.lan/admin (changing "box.lan" to be as above!)' +echo -e 'PLEASE READ "What are the default passwords?" and "How do I customize my' +echo -e 'Internet-in-a-Box home page?" at http://FAQ.IIAB.IO\n' + +echo -e "(3) Please run the 'iiab-diagnostics' command, to generate a URL summarizing" +echo -e "your IIAB configuration, for volunteers seeking to help you. We strongly" +echo -e "encourage you to share this URL also when connecting with others in the IIAB" +echo -e "global community, learning from other initiatives in your region and beyond!\n" + +#echo -e "(3) If you're installing IIAB over Wi-Fi (instead of Ethernet) remember to run" +#echo -e "'iiab-hotspot-on' at the VERY END, when you're ready to ACTIVATE YOUR IIAB's" +#echo -e "INTERNAL WI-FI HOTSPOT. CAUTION: this permanently kills your IIAB's Internet" +#echo -e "(over Wi-Fi anyway) until you later run 'iiab-hotspot-off'. CAVEAT: these" +#echo -e "two commands only work with Raspberry Pi as of 2019-09-30.\n" + +if [ $INTERACTIVE == 1 ]; then + echo -ne "HIT [Enter] TO REBOOT, CONFIRMING YOU'VE" '"photographed" THE ABOVE PARAGRAPHS: ' + read ans < /dev/tty + # Sets hostname, improves RTC + memory mgmt, starts BitTorrents if needed, etc! + reboot +fi From 481290022e9013b7041f4703d0f39d1a9eded190 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 1 Sep 2020 22:54:23 +0100 Subject: [PATCH 02/42] self-install from git repo --- iiab-upgrade | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 35f163f0..ebf0af32 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -86,13 +86,12 @@ function update_self() { fi NEW_VERSION=$(grep RELEASE /opt/iiab/iiab-factory/$SCRIPT | awk -F = '{print $2}' | head -n 1) + cp $SCRIPT /usr/sbin/$SCRIPT + echo "Latest $SCRIPT now installed" if [ $NEW_VERSION -gt $RELEASE ]; then - cp /opt/iiab/iiab-factory/$SCRIPT /usr/sbin/$SCRIPT - echo "Latest $SCRIPT now installed" + echo " *** Relaunching $SCRIPT after update" cat > "$SELFUPDATE_SCRIPT" << EOF #!/bin/bash - echo " *** Relaunching $SCRIPT after update" -# exec env /bin/bash /usr/sbin/$SCRIPT exec /usr/sbin/$SCRIPT EOF exec /bin/bash $SELFUPDATE_SCRIPT From 56d4f52219a4f57ea7f109605fc247b17995b488 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 2 Sep 2020 01:23:10 +0100 Subject: [PATCH 03/42] upgrade_roles https://github.com/iiab/iiab-factory/pull/110/files --- iiab-upgrade | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index ebf0af32..a81f5f1b 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -23,7 +23,7 @@ if [ "$1" = "--upgrade" ]; then shift 1 rm $FLAGS/iiab*complete || true UPDATE=1 - REINSTALL="--reinstall" +# REINSTALL="--reinstall" fi if [ "$1" = "--reinstall" ]; then @@ -31,11 +31,6 @@ if [ "$1" = "--reinstall" ]; then REINSTALL="--reinstall" fi -# cleanup -#if [ -f $SELFUPDATE_SCRIPT ]; then -# rm $SELFUPDATE_SCRIPT -#fi - # Subroutines for upgrade logic check_branch(){ git -C $BASEDIR/iiab branch | grep \* | grep release-7 | wc -l @@ -304,7 +299,16 @@ echo -e "โ”‚ child script ./iiab-install -- both avoid repeating any of the 9 echo -e "โ”‚ โ”‚" echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" cd $BASEDIR/iiab/ -./iiab-install $REINSTALL +if [ $UPDATE == 1 ]; then + if [ -f upgrade_roles ]; then + for force in $(cat upgrade_roles); do + sed -i -e '/^$force/d' $CONFDIR/iiab_state.yml + done + fi + ./iiab-configure +else + ./iiab-install $REINSTALL +fi echo -e "Install Admin Console... (also runs iiab-get-kiwix-cat to d/l Kiwix catalog, and installs Dynamic Menuing for /library/www/html/home/index.html)\n" if [ ! -f $FLAGDIR/iiab-admin-console-complete ] || [ $UPDATE == 1 ]; then @@ -399,9 +403,14 @@ echo -e "global community, learning from other initiatives in your region and be #echo -e "(over Wi-Fi anyway) until you later run 'iiab-hotspot-off'. CAVEAT: these" #echo -e "two commands only work with Raspberry Pi as of 2019-09-30.\n" +# cleanup +if [ -f $SELFUPDATE_SCRIPT ]; then + rm $SELFUPDATE_SCRIPT +fi if [ $INTERACTIVE == 1 ]; then echo -ne "HIT [Enter] TO REBOOT, CONFIRMING YOU'VE" '"photographed" THE ABOVE PARAGRAPHS: ' read ans < /dev/tty # Sets hostname, improves RTC + memory mgmt, starts BitTorrents if needed, etc! reboot fi +exit 0 From 98a4c9d3d876989d510f8c6599ab977b989a89f6 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 2 Sep 2020 04:59:35 +0100 Subject: [PATCH 04/42] iiab_revision --- iiab-upgrade | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index a81f5f1b..1a5decb0 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -6,6 +6,7 @@ SCRIPT=iiab-upgrade RELEASE=1 BASEDIR=/opt/iiab CONFDIR=/etc/iiab +IIABENV=$CONFDIR/iiab.env FLAGDIR=$CONFDIR/install-flags APT_PATH=/usr/bin/apt # Avoids problematic /usr/local/bin/apt on Linux Mint REINSTALL="" @@ -60,6 +61,7 @@ function update_master(){ echo -e "\nUpdating iiab" git checkout master git pull + NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $2}') fi cd $BASEDIR if [ -d iiab-admin-console ]; then @@ -112,6 +114,7 @@ if [ `check_branch` -gt 0 ]; then echo "remaning on release-7.X branch updating" cd $BASEDIR/iiab git pull + NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $2}') fi fi @@ -300,9 +303,14 @@ echo -e "โ”‚ echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" cd $BASEDIR/iiab/ if [ $UPDATE == 1 ]; then + source $IIABENV + OLDREV=$IIAB_REVISION if [ -f upgrade_roles ]; then - for force in $(cat upgrade_roles); do - sed -i -e '/^$force/d' $CONFDIR/iiab_state.yml + for REV in $(cat upgrade_roles | awk '{print $1}'); do + if [ $REV -gt $OLDREV ]; then + force=$(grep $REV upgrade_roles | awk '{print $2}') + sed -i -e '/^$force/d' $CONFDIR/iiab_state.yml + fi done fi ./iiab-configure From add7efada149365b1b3d5cf68d85edf0d1386ef1 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 2 Sep 2020 05:09:01 +0100 Subject: [PATCH 05/42] fall though to iiab-install on first pass --- iiab-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iiab-upgrade b/iiab-upgrade index 1a5decb0..0494e1b4 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -302,7 +302,7 @@ echo -e "โ”‚ child script ./iiab-install -- both avoid repeating any of the 9 echo -e "โ”‚ โ”‚" echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" cd $BASEDIR/iiab/ -if [ $UPDATE == 1 ]; then +if [ -f $IIABENV ] && [ $UPDATE == 1 ]; then source $IIABENV OLDREV=$IIAB_REVISION if [ -f upgrade_roles ]; then From 8bda0da21b973cab4ff3c629773f695b5d4bb7e2 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 2 Sep 2020 05:38:10 +0100 Subject: [PATCH 06/42] skipping re-exec --- iiab-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iiab-upgrade b/iiab-upgrade index 0494e1b4..fb44b7c6 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -93,7 +93,7 @@ function update_self() { EOF exec /bin/bash $SELFUPDATE_SCRIPT else - echo " Latest $SCRIPT is already installed" + echo "Latest $SCRIPT is already running skipping re-exec" fi } From 1623df6c2aaabacb505bd6b8b25450c358bd5d2a Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 3 Sep 2020 07:55:22 +0100 Subject: [PATCH 07/42] grouping - move kernel test to the end --- iiab-upgrade | 68 +++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index fb44b7c6..2cac8cae 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -97,6 +97,21 @@ EOF fi } +# Subroutine compares software version numbers. Generates rare false positives +# like "1.0 > 1" and "2.4.0 > 2.4". Avoid risks by structuring conditionals w/ +# a consistent # of decimal points e.g. "if version_gt w.x.y.z a.b.c.d; then" +version_gt() { [ "$(printf '%s\n' "$@" | sort -V | head -1)" != "$1" ]; } + +# A. Subroutine for B. and D. Returns true (0) if username ($1) exists with password ($2) +check_user_pwd() { + # $meth (hashing method) is typically '6' which implies 5000 rounds + # of SHA-512 per /etc/login.defs -> /etc/pam.d/common-password + meth=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f2) + salt=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f3) + hash=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f4) + [ $(python3 -c "import crypt; print(crypt.crypt('$2', '\$$meth\$$salt'))") == "\$$meth\$$salt\$$hash" ] +} + # start exec here update_self @@ -118,16 +133,6 @@ if [ `check_branch` -gt 0 ]; then fi fi -# A. Subroutine for B. and D. Returns true (0) if username ($1) exists with password ($2) -check_user_pwd() { - # $meth (hashing method) is typically '6' which implies 5000 rounds - # of SHA-512 per /etc/login.defs -> /etc/pam.d/common-password - meth=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f2) - salt=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f3) - hash=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f4) - [ $(python3 -c "import crypt; print(crypt.crypt('$2', '\$$meth\$$salt'))") == "\$$meth\$$salt\$$hash" ] -} - # B. Ask for password change if pi/raspberry default remains if check_user_pwd "pi" "raspberry"; then echo -e "\n\nRaspberry Pi's are COMPROMISED often if the default password is not changed!\n" @@ -257,25 +262,6 @@ if [ $INTERACTIVE == 1 ]; then read -t 5 ans < /dev/tty fi -# Subroutine compares software version numbers. Generates rare false positives -# like "1.0 > 1" and "2.4.0 > 2.4". Avoid risks by structuring conditionals w/ -# a consistent # of decimal points e.g. "if version_gt w.x.y.z a.b.c.d; then" -version_gt() { [ "$(printf '%s\n' "$@" | sort -V | head -1)" != "$1" ]; } - -# Verify that Raspbian is running a recent enough kernel. As Raspbian -# kernel 1333 has wifi issues https://github.com/iiab/iiab/issues/2497. -CURR_KERN=`uname -v | awk '{print $1}' | sed -e s'/#//'` -echo "Found Kernel ""$CURR_KERN" -if [ -f /etc/rpi-issue ] && version_gt $MIN_RPI_KERN $CURR_KERN; then - echo -e "\033[31;5mWARNING: Kernel ""$MIN_RPI_KERN"" or higher required with Raspbian.\033[0m" -# echo -e "\033[31;5mPLEASE RUN 'apt update' then 'apt install raspberrypi-kernel' then reboot.\033[0m" - echo -e "\033[31;5mTHEN IF NEC run 'rpi-update' to install a more recent kernel post-install, then reboot.\033[0m" - echo -e "'enter' to continue" - if [ $INTERACTIVE == 1 ]; then - read -t 10 ans < /dev/tty - fi -fi - ######################### INTERACTIVE STUFF IS ABOVE ######################### @@ -411,14 +397,32 @@ echo -e "global community, learning from other initiatives in your region and be #echo -e "(over Wi-Fi anyway) until you later run 'iiab-hotspot-off'. CAVEAT: these" #echo -e "two commands only work with Raspberry Pi as of 2019-09-30.\n" +# Verify that Raspbian is running a recent enough kernel. As Raspbian +# kernel 1333 has wifi issues https://github.com/iiab/iiab/issues/2497. +CURR_KERN=`uname -v | awk '{print $1}' | sed -e s'/#//'` +echo "Found Kernel ""$CURR_KERN" +if [ -f /etc/rpi-issue ] && version_gt $MIN_RPI_KERN $CURR_KERN; then + echo -e "\033[31;5mWARNING: Kernel ""$MIN_RPI_KERN"" or higher required with Raspbian.\033[0m" +# echo -e "\033[31;5mPLEASE RUN 'apt update' then 'apt install raspberrypi-kernel' then reboot.\033[0m" + echo -e "\033[31;5mTHEN IF NEC run 'rpi-update' to install a more recent kernel \033[0m" + echo -e "\033[31;5mPlease check with developers before running this command" +# if [ $INTERACTIVE == 1 ]; then +# echo -e "'enter' to continue" +# read -t 10 ans < /dev/tty +# fi +fi + # cleanup if [ -f $SELFUPDATE_SCRIPT ]; then rm $SELFUPDATE_SCRIPT fi if [ $INTERACTIVE == 1 ]; then - echo -ne "HIT [Enter] TO REBOOT, CONFIRMING YOU'VE" '"photographed" THE ABOVE PARAGRAPHS: ' + echo -ne "HIT [Y] [Enter] TO REBOOT, [Enter] to exit, CONFIRMING YOU'VE" '"photographed" THE ABOVE PARAGRAPHS: ' + ans=n read ans < /dev/tty - # Sets hostname, improves RTC + memory mgmt, starts BitTorrents if needed, etc! - reboot + if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then + reboot + fi fi +echo -e "Remember to reboot" exit 0 From 8ac513c5c67aedec955af4f8aee7dc87328bfc43 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 3 Sep 2020 23:08:57 +0100 Subject: [PATCH 08/42] whiptail for check_branch dialog --- iiab-upgrade | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 2cac8cae..b1aa0efc 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -116,14 +116,8 @@ check_user_pwd() { update_self if [ `check_branch` -gt 0 ]; then - echo -e "\nFound release-7.X branch would you like (re)install using the latest master?" - echo -e "[Y/n]\n n default 5 second timeout" - ans="n" -# if [ $INTERACTIVE == 1 ]; then -# read -t 5 ans < /dev/tty -# fi - read -t 5 ans < /dev/tty - if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then + if whiptail --yesno "\nFound release-7.X branch would you like (re)install using the latest master?" 20 60 2 3>&1 1>&2 2>&3; then + echo "matched yes for master" UPDATE=1 else echo "remaning on release-7.X branch updating" From 4f0fa744b0ce2a273d839e499589e1fae1b833b6 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 4 Sep 2020 19:36:42 +0100 Subject: [PATCH 09/42] refactor check_revision --- iiab-upgrade | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index b1aa0efc..4bad2a22 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -12,6 +12,7 @@ APT_PATH=/usr/bin/apt # Avoids problematic /usr/local/bin/apt on Linux Mint REINSTALL="" INTERACTIVE=0 UPDATE=0 +MASTER=1 MIN_RPI_KERN=1336 SELFUPDATE_SCRIPT="/tmp/.updateScript.sh" # scrape the command line @@ -72,6 +73,18 @@ function update_master(){ fi } + +function check_revision(){ + if [ -f $IIABENV ]; then + source $IIABENV + OLDREV=$IIAB_REVISION + if [ $NEWREV -gt $OLDREV ]; then + echo -e "\nNEW IIAB Revison Found\n" + UPDATE=1 + fi + fi +} + function update_self() { echo " *** Performing self-update" cd $BASEDIR @@ -118,10 +131,11 @@ update_self if [ `check_branch` -gt 0 ]; then if whiptail --yesno "\nFound release-7.X branch would you like (re)install using the latest master?" 20 60 2 3>&1 1>&2 2>&3; then echo "matched yes for master" - UPDATE=1 + use_master else echo "remaning on release-7.X branch updating" cd $BASEDIR/iiab + MASTER=0 git pull NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $2}') fi @@ -160,6 +174,11 @@ if [ -f $FLAGDIR/iiab-complete ]; then exit 0 fi +if [ $MASTER == 1 ]; then + update_master +fi +check_revision + mkdir -p $FLAGDIR # E. Position & customize $CONFDIR/local_vars.yml cd $CONFDIR @@ -214,11 +233,6 @@ else fi fi -if [ $UPDATE == 1 ]; then - use_master - update_master -fi - # F. Mandate OS SECURITY/UPDATES if 'apt update' has any (IF SO REBOOT) # Educate implementer while waiting for 'apt update' echo -e "\n\n โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" @@ -282,17 +296,13 @@ echo -e "โ”‚ child script ./iiab-install -- both avoid repeating any of the 9 echo -e "โ”‚ โ”‚" echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" cd $BASEDIR/iiab/ -if [ -f $IIABENV ] && [ $UPDATE == 1 ]; then - source $IIABENV - OLDREV=$IIAB_REVISION - if [ -f upgrade_roles ]; then - for REV in $(cat upgrade_roles | awk '{print $1}'); do - if [ $REV -gt $OLDREV ]; then - force=$(grep $REV upgrade_roles | awk '{print $2}') - sed -i -e '/^$force/d' $CONFDIR/iiab_state.yml - fi - done - fi +if [ -f upgrade_roles ] && [ $UPDATE == 1 ]; then + for REV in $(cat upgrade_roles | awk '{print $1}'); do + if [ $REV -gt $OLDREV ]; then + force=$(grep $REV upgrade_roles | awk '{print $2}') + sed -i -e '/^$force/d' $CONFDIR/iiab_state.yml + fi + done ./iiab-configure else ./iiab-install $REINSTALL From a791f409a21bb2f8aae62f0123c368e65f9ef4bc Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 12 Sep 2020 07:38:32 +0100 Subject: [PATCH 10/42] check complete flag after check_revision --- iiab-upgrade | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 4bad2a22..39a03f7e 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -168,17 +168,17 @@ if check_user_pwd "iiab-admin" "g0adm1n"; then fi fi -if [ -f $FLAGDIR/iiab-complete ]; then - echo -e "\n\nIIAB INSTALLATION (/usr/sbin/iiab) IS ALREADY COMPLETE -- per existence of:" - echo -e "$FLAGDIR/iiab-complete -- nothing to do.\n" - exit 0 -fi - if [ $MASTER == 1 ]; then update_master fi check_revision +if [ -f $FLAGDIR/iiab-complete ] && [ $UPDATE == 0 ]; then + echo -e "\n\nIIAB INSTALLATION (/usr/sbin/iiab) IS ALREADY COMPLETE -- per existence of:" + echo -e "$FLAGDIR/iiab-complete -- nothing to do.\n" + exit 0 +fi + mkdir -p $FLAGDIR # E. Position & customize $CONFDIR/local_vars.yml cd $CONFDIR From 934f1be19119b9a9c411c303cc80b4011c280a7d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 4 Sep 2020 01:37:09 +0100 Subject: [PATCH 11/42] 7.2-install.txt --- 7.2-install.txt | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 7.2-install.txt diff --git a/7.2-install.txt b/7.2-install.txt new file mode 100644 index 00000000..d6dc814d --- /dev/null +++ b/7.2-install.txt @@ -0,0 +1,100 @@ +#!/bin/bash +# Copied from: https://github.com/iiab/iiab-factory/blob/master/install.txt + +# To install Internet-in-a-Box (IIAB) 7.2 / pre-release onto Raspberry Pi OS, +# Ubuntu 20.04 or Debian 10, run this 1-line installer: +# +# curl d.iiab.io/install.txt | sudo bash + +# 1. WARNING: NOOBS IS *NOT* SUPPORTED, as its partitioning is very different. +# On a Raspberry Pi, WE RECOMMEND YOU INSTALL THE LATEST RASPBERRY PI OS: +# https://www.raspberrypi.org/documentation/installation/installing-images/README.md +# To attempt IIAB 7.2 on another Linux see the full/manual instructions: +# https://github.com/iiab/iiab/wiki/IIAB-Installation#do-everything-from-scratch + +# 2. An Ethernet cable is HIGHLY RECOMMENDED during installation, as this is +# more reliable than Wi-Fi (and faster!) + +# 3. Run 'sudo raspi-config' on RPi, to set LOCALISATION OPTIONS + +# 4. OPTIONAL: if you have slow/pricey Internet, pre-position KA Lite's +# mandatory 0.9 GB English Pack (en.zip) within /tmp -- you can grab a copy +# from http://pantry.learningequality.org/downloads/ka-lite/0.17/content/contentpacks/en.zip + +# 5. WHEN YOU RUN 1-LINE INSTALLER 'curl d.iiab.io/install.txt | sudo bash' +# YOU THEN NEED TO TYPE IN YOUR PASSWORD IF ON UBUNTU/DEBIAN/ETC (for sudo) +# ^^^ ^^^^ ^^^^ ^^ ^^^^ ^^ ^^^^ ^^^^^^^^ + +# 6. Follow on-screen instructions (TYPE 'sudo iiab' TO RESUME IF EVER NECESS!) + +# 7. About 1-2 hours later, it will announce that INTERNET-IN-A-BOX (IIAB) +# SOFTWARE INSTALL IS COMPLETE, prompting you to reboot...TO ADD CONTENT! + +# Thanks For Building Your Own Library To Serve One & All +# +# DRAFT IIAB 7.2 Release Notes: +# https://github.com/iiab/iiab/wiki/IIAB-7.2-Release-Notes +# +# Write to bugs @ iiab.io if you find issues, Thank You! Special Thanks to the +# countries+communities+volunteers who worked non-stop to bring about IIAB 7.2! +# +# IIAB Development Team +# http://FAQ.IIAB.IO + +# Copied from: https://github.com/jvonau/iiab-factory/blob/jv-pi-gen/install.txt +set -e # Exit on error (avoids snowballing) +export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions +BASE=/opt/iiab +BRANCH=release-7.2 +ADMBRANCH=master +echo -e "\n\nDOWNLOAD (CLONE) IIAB'S 3 KEY REPOS INTO $BASE ...\n" +/usr/bin/apt -y install git nano whiptail +mkdir -p $BASE +cd $BASE +echo +if [ -d iiab-factory ]; then + echo -e "REPO iiab-factory EXISTS? -- updating master branch" + cd iiab-factory + git checkout master + git pull + git branch -D $BRANCH &> /dev/null || true + git checkout -b $BRANCH + cp $BASE/iiab-factory/iiab /usr/sbin/iiab +else + echo -e "Cloning iiab-factory" + git clone https://github.com/iiab/iiab-factory --depth 1 + cd iiab-factory + git checkout -b $BRANCH + cp $BASE/iiab-factory/iiab /usr/sbin/iiab +fi +cd $BASE +echo +if [ -d iiab ]; then + echo -e "REPO iiab EXISTS? Consider 'sudo iiab --upgrade'" #FIXME +else + cd iiab + git clone https://github.com/iiab/iiab --depth 10 --branch master + git checkout -b $BRANCH # this goes +# post branching below +# git clone https://github.com/iiab/iiab --depth 10 --branch $BRANCH +# git checkout -b master +# git config branch.master.remote origin +# git config branch.master.merge refs/heads/master +# git checkout $BRANCH +fi +cd $BASE +echo +if [ -d iiab-admin-console ]; then + echo -e "REPO iiab-admin-console EXISTS? Consider 'sudo iiab --upgrade'" #FIXME +else + git clone https://github.com/iiab/iiab-admin-console --depth 1 --branch ADMBRANCH + git checkout -b $BRANCH # this goes +# post branching below +# git checkout -b master +# git config branch.master.remote origin +# git config branch.master.merge refs/heads/master +# git checkout $BRANCH +fi + +# Run install script! +/usr/sbin/iiab From fd50cb30f85b7ae8a06835bfa662866020517ca7 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 4 Sep 2020 06:49:28 +0100 Subject: [PATCH 12/42] ansible --- iiab-upgrade | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 39a03f7e..00ec317c 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -4,6 +4,8 @@ set -e # Exit on error (avoids snowballing) export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions SCRIPT=iiab-upgrade RELEASE=1 +CURR_VER="" # Ansible version you currently have installed +GOOD_VER="2.9.13" # preferred Ansible version BASEDIR=/opt/iiab CONFDIR=/etc/iiab IIABENV=$CONFDIR/iiab.env @@ -240,10 +242,18 @@ echo -e " โ–ˆโ–ˆ echo -e " โ–ˆโ–ˆ RUN 'sudo iiab' IF THIS INSTALL SCRIPT EVER FAILS, TO TRY TO CONTINUE! โ–ˆโ–ˆ" echo -e " โ–ˆโ–ˆ โ–ˆโ–ˆ" echo -e " โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" +echo -e "\n" +if [ $INTERACTIVE == 1 ]; then + echo -ne "\nHit [ENTER] to confirm you'll TRY TO RERUN 'sudo iiab' IF THERE IS A PROBLEM: " + read -t 5 ans < /dev/tty +fi + echo -e "\n\n'apt update' is checking for OS updates...\n" #echo -e "2019-07-11 TEMP WORKAROUND FOR RASPBIAN BUSTER'S testing->stable apt GLITCH...\nDetails @ https://github.com/iiab/iiab/issues/1856\n" #apt -y update || true # Overrides 'set -e' #echo -e "\nNOW THE REAL 'apt update' WILL RUN...\n" + +# catch's ansible updates when apt runs $APT_PATH -qq update > /tmp/apt.stdout 2> /tmp/apt.stderr || true # Overrides 'set -e' if [ $(wc -c < /tmp/apt.stderr) -gt 82 ]; then # apt.stderr typically contains exactly 82 characters when there are no errors, no matter the primary locale, i.e. 3-line file "\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n\n" ...OR... in other cases more than 82, e.g. many lines of errors when apt is busy/locked/offline/etc echo -e "'apt update' FAILED. VERIFY YOU'RE ONLINE and resolve all errors below:\n" @@ -265,9 +275,20 @@ elif grep -q 'apt list --upgradable' /tmp/apt.stdout; then # apt.stdout typic fi cat /tmp/apt.stdout # "All packages are up to date.\n" -if [ $INTERACTIVE == 1 ]; then - echo -ne "\nHit [ENTER] to confirm you'll TRY TO RERUN 'sudo iiab' IF THERE IS A PROBLEM: " - read -t 5 ans < /dev/tty +# add logic to force updates later +# 2.9.13 -> 2.10.X might need the removal of /etc/ansible/ansible.cfg +if [ $(command -v ansible-playbook) ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd" + CURR_VER=`ansible --version | head -1 | awk '{print $2}'` # To match iiab-install. Was: CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "` + echo -e "\n\nCURRENTLY INSTALLED ANSIBLE: $CURR_VER" + if version_gt $CURR_VER $GOOD_VER; then + echo -e "$CURR_VER is >= $GOOD_VER, skipping install!" + else + echo -e "(Re)Install Ansible..." + $BASEDIR/iiab/scripts/ansible + fi +else + echo -e "Install Ansible..." + $BASEDIR/iiab/scripts/ansible fi @@ -281,10 +302,7 @@ if [ -e /dev/mmcblk0p2 ]; then fi # I. Install Ansible + 2 IIAB repos -echo -e "\n\nINSTALL ANSIBLE + CORE IIAB SOFTWARE + ADMIN CONSOLE / CONTENT PACK MENUS...\n" - -echo -e "Install Ansible..." -$BASEDIR/iiab/scripts/ansible +#echo -e "\n\nINSTALL ANSIBLE + CORE IIAB SOFTWARE + ADMIN CONSOLE / CONTENT PACK MENUS...\n" echo -e "\nโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”" echo -e "โ”‚ โ”‚" From 2f7f4286e11824b4dd9e581d7ba673cb6b268ce3 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 7 Sep 2020 12:24:42 +0100 Subject: [PATCH 13/42] OS check --- 7.2-install.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/7.2-install.txt b/7.2-install.txt index d6dc814d..69cbb9c6 100644 --- a/7.2-install.txt +++ b/7.2-install.txt @@ -47,6 +47,29 @@ export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions BASE=/opt/iiab BRANCH=release-7.2 ADMBRANCH=master +OS=`grep ^ID= /etc/*elease|cut -d= -f2` +OS=${OS//\"/} +if [ -f /etc/rpi-issue ]; then + OS="raspbian" +fi +VERSION_ID=`grep VERSION_ID /etc/*elease | cut -d= -f2` +VERSION_ID=${VERSION_ID//\"/} +VERSION_ID=${VERSION_ID%%.*} +OS_VER=$OS-$VERSION_ID + +not_supported(){ + echo "Can't detect supported Distro" +} + +case $OS_VER in +"debian-10" | "ubuntu-20" | "linuxmint-20" | "raspbian-10") + ;; +*) + not_supported + exit 1 + ;; +esac + echo -e "\n\nDOWNLOAD (CLONE) IIAB'S 3 KEY REPOS INTO $BASE ...\n" /usr/bin/apt -y install git nano whiptail mkdir -p $BASE @@ -60,12 +83,14 @@ if [ -d iiab-factory ]; then git branch -D $BRANCH &> /dev/null || true git checkout -b $BRANCH cp $BASE/iiab-factory/iiab /usr/sbin/iiab + cp $BASE/iiab-factory/iiab-upgrade /usr/sbin/iiab-upgrade else echo -e "Cloning iiab-factory" git clone https://github.com/iiab/iiab-factory --depth 1 cd iiab-factory git checkout -b $BRANCH cp $BASE/iiab-factory/iiab /usr/sbin/iiab + cp $BASE/iiab-factory/iiab-upgrade /usr/sbin/iiab-upgrade fi cd $BASE echo From a68cfe36be4718e457c968beee803e06c8512646 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 9 Sep 2020 11:20:23 -0500 Subject: [PATCH 14/42] --remove-destination --- 7.2-install.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/7.2-install.txt b/7.2-install.txt index 69cbb9c6..212e1f2c 100644 --- a/7.2-install.txt +++ b/7.2-install.txt @@ -82,8 +82,8 @@ if [ -d iiab-factory ]; then git pull git branch -D $BRANCH &> /dev/null || true git checkout -b $BRANCH - cp $BASE/iiab-factory/iiab /usr/sbin/iiab - cp $BASE/iiab-factory/iiab-upgrade /usr/sbin/iiab-upgrade + cp --remove-destination $BASE/iiab-factory/iiab /usr/sbin/iiab + cp --remove-destination $BASE/iiab-factory/iiab-upgrade /usr/sbin/iiab-upgrade else echo -e "Cloning iiab-factory" git clone https://github.com/iiab/iiab-factory --depth 1 From e976f85ed6eb5561a3ff9baba0bb43da54aeeee0 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 4 Sep 2020 03:42:50 +0100 Subject: [PATCH 15/42] update_self format --- iiab-upgrade | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 00ec317c..7895a135 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -95,20 +95,19 @@ function update_self() { cd iiab-factory git checkout master git pull - fi - - NEW_VERSION=$(grep RELEASE /opt/iiab/iiab-factory/$SCRIPT | awk -F = '{print $2}' | head -n 1) - cp $SCRIPT /usr/sbin/$SCRIPT - echo "Latest $SCRIPT now installed" - if [ $NEW_VERSION -gt $RELEASE ]; then - echo " *** Relaunching $SCRIPT after update" - cat > "$SELFUPDATE_SCRIPT" << EOF - #!/bin/bash - exec /usr/sbin/$SCRIPT + NEW_VERSION=$(grep RELEASE $SCRIPT | awk -F = '{print $2}' | head -n 1) + cp $SCRIPT /usr/sbin/$SCRIPT + echo "Latest $SCRIPT now installed" + if [ $NEW_VERSION -gt $RELEASE ]; then + echo " *** Relaunching $SCRIPT after update" + cat > "$SELFUPDATE_SCRIPT" << EOF +#!/bin/bash +exec /usr/sbin/$SCRIPT EOF - exec /bin/bash $SELFUPDATE_SCRIPT - else - echo "Latest $SCRIPT is already running skipping re-exec" + exec /bin/bash $SELFUPDATE_SCRIPT + else + echo "Latest $SCRIPT is already running skipping re-exec" + fi fi } From e81f34b1a05c88f0fd3de88da6dbb641f483103a Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 4 Sep 2020 02:11:28 +0100 Subject: [PATCH 16/42] whiptail for passwords --- iiab-upgrade | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 7895a135..17fdd319 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -144,10 +144,13 @@ fi # B. Ask for password change if pi/raspberry default remains if check_user_pwd "pi" "raspberry"; then - echo -e "\n\nRaspberry Pi's are COMPROMISED often if the default password is not changed!\n" - echo -n "What password do you want for GNU/Linux user 'pi' ? " - read -t 5 ans < /dev/tty # Whines but doesn't change password if [Enter] - echo pi:"$ans" | chpasswd || true # Overrides 'set -e' + if [ $INTERACTIVE == 1 ]; then + PASSWORD=$(whiptail --passwordbox " +Raspberry Pi's are COMPROMISED often if the default password is not changed! +What password do you want for GNU/Linux user 'pi' ? +press [Enter] for no change " 12 78 --title "password dialog" 3>&1 1>&2 2>&3) + echo pi:$PASSWORD | chpasswd 2>&1 > /dev/null || true # Overrides 'set -e' + fi fi # C. Create user 'iiab-admin' as nec, with default password @@ -158,14 +161,13 @@ fi # D. Ask for password change if iiab-admin/g0adm1n default remains if check_user_pwd "iiab-admin" "g0adm1n"; then - echo -e "\n\nUser 'iiab-admin' retains default password 'g0adm1n' per http://FAQ.IIAB.IO\n" - - echo -e "This is for login to Internet-in-a-Box's Admin Console (http://box.lan/admin)\n" if [ $INTERACTIVE == 1 ]; then - echo -n "What password do you want for GNU/Linux user 'iiab-admin' ? " - echo -n "press [Enter] for no change" - read -t 15 ans < /dev/tty # Whines but doesn't change password if [Enter] - echo iiab-admin:"$ans" | chpasswd || true # Overrides 'set -e' + PASSWORD2=$(whiptail --passwordbox " +User 'iiab-admin' retains default password 'g0adm1n' per http://FAQ.IIAB.IO +This is for login to Internet-in-a-Box's Admin Console (http://box.lan/admin) +What password do you want for GNU/Linux user 'iiab-admin' ? +press [Enter] for no change " 12 78 --title "password dialog" 3>&1 1>&2 2>&3) + echo iiab-admin:$PASSWORD2 | chpasswd 2>&1 > /dev/null || true # Overrides 'set -e' fi fi From 78345b2a5c787a0fb4cc828dc8fc9b028ecad1a9 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 13 Sep 2020 10:48:44 +0100 Subject: [PATCH 17/42] use 'role directory & installed marker differ' from runrole --- iiab-upgrade | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/iiab-upgrade b/iiab-upgrade index 17fdd319..2c64ab54 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -318,8 +318,20 @@ cd $BASEDIR/iiab/ if [ -f upgrade_roles ] && [ $UPDATE == 1 ]; then for REV in $(cat upgrade_roles | awk '{print $1}'); do if [ $REV -gt $OLDREV ]; then + echo "found REV $REV" force=$(grep $REV upgrade_roles | awk '{print $2}') - sed -i -e '/^$force/d' $CONFDIR/iiab_state.yml + echo "REV has $force" + if [ "$force" == "calibre-web" ]; then # role directory & installed marker differ + force=calibreweb + elif [ "$force" == "httpd" ]; then # role directory & installed marker differ + force=apache + elif [ "$force" == "osm-vector-maps" ]; then # role directory & installed marker differ + force=osm_vector_maps + else + echo "no role execptions found" + fi + echo -e "\nREV has $force - removing from iiab_state.yml" + sed -i "/^$force/d" $CONFDIR/iiab_state.yml fi done ./iiab-configure From 746c6adb9d1a2ea922203df4800536bff87f0704 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 16 Sep 2020 05:53:05 +0100 Subject: [PATCH 18/42] add oldver feedback --- iiab-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iiab-upgrade b/iiab-upgrade index 2c64ab54..bc49f402 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -318,7 +318,7 @@ cd $BASEDIR/iiab/ if [ -f upgrade_roles ] && [ $UPDATE == 1 ]; then for REV in $(cat upgrade_roles | awk '{print $1}'); do if [ $REV -gt $OLDREV ]; then - echo "found REV $REV" + echo "found REV $REV - OLDREV $OLDREV" force=$(grep $REV upgrade_roles | awk '{print $2}') echo "REV has $force" if [ "$force" == "calibre-web" ]; then # role directory & installed marker differ From 152ddba2785eaf985c4b2f3d8bcfc5536aa9605c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 16 Sep 2020 21:15:26 +0100 Subject: [PATCH 19/42] revert the use of -t --- iiab-upgrade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index bc49f402..e52dd496 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -225,8 +225,8 @@ else echo -en "\nEdit /etc/iiab/local_vars.yml to customize your Internet-in-a-Box? [Y/n] " ans="n" - if [ "$INTERACTIVE" == 1 ]; then - read -t 5 ans < /dev/tty + if [ $INTERACTIVE == 1 ]; then + read ans < /dev/tty fi if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then exit 0 @@ -246,7 +246,7 @@ echo -e " โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ echo -e "\n" if [ $INTERACTIVE == 1 ]; then echo -ne "\nHit [ENTER] to confirm you'll TRY TO RERUN 'sudo iiab' IF THERE IS A PROBLEM: " - read -t 5 ans < /dev/tty + read ans < /dev/tty fi echo -e "\n\n'apt update' is checking for OS updates...\n" @@ -443,7 +443,7 @@ if [ -f /etc/rpi-issue ] && version_gt $MIN_RPI_KERN $CURR_KERN; then echo -e "\033[31;5mPlease check with developers before running this command" # if [ $INTERACTIVE == 1 ]; then # echo -e "'enter' to continue" -# read -t 10 ans < /dev/tty +# read ans < /dev/tty # fi fi From c24e996e6354c1932ff139e566c4f6cdf92d8854 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 17 Sep 2020 00:32:54 +0100 Subject: [PATCH 20/42] ansible upgrades from 2.9.x to 2.10.1 use apt to remove ansible first Avoids a confict over /etc/ansible/ansible.cfg Unpacking ansible-base (2.10.1-1ppa~bionic) ... dpkg: error processing archive /var/cache/apt/archives/ansible-base_2.10.1-1ppa~bionic_all.deb (--unpack): trying to overwrite '/etc/ansible/ansible.cfg', which is also in package ansible 2.9.13-1ppa~bionic dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Errors were encountered while processing: /var/cache/apt/archives/ansible-base_2.10.1-1ppa~bionic_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1) --- iiab-upgrade | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index e52dd496..338a9183 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -3,9 +3,9 @@ set -e # Exit on error (avoids snowballing) export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions SCRIPT=iiab-upgrade -RELEASE=1 +RELEASE=2 CURR_VER="" # Ansible version you currently have installed -GOOD_VER="2.9.13" # preferred Ansible version +GOOD_VER="2.10.1" # preferred Ansible version BASEDIR=/opt/iiab CONFDIR=/etc/iiab IIABENV=$CONFDIR/iiab.env @@ -276,15 +276,17 @@ elif grep -q 'apt list --upgradable' /tmp/apt.stdout; then # apt.stdout typic fi cat /tmp/apt.stdout # "All packages are up to date.\n" -# add logic to force updates later -# 2.9.13 -> 2.10.X might need the removal of /etc/ansible/ansible.cfg +# think version_gt is choking on 2913 vs 2101 with the .'s removed but my 2.10.1 install skipped +# ansible correctly when good_ver was 2.9.13. Changed back on the fly to 2.9.13 while live testing +# and the install appears to not skip when 2.9.13 == 2.9.13 and we end up with the noted apt error. if [ $(command -v ansible-playbook) ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd" CURR_VER=`ansible --version | head -1 | awk '{print $2}'` # To match iiab-install. Was: CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "` echo -e "\n\nCURRENTLY INSTALLED ANSIBLE: $CURR_VER" - if version_gt $CURR_VER $GOOD_VER; then + if version_gt $CURR_VER $GOOD_VER || [ $CURR_VER == $GOOD_VER ]; then echo -e "$CURR_VER is >= $GOOD_VER, skipping install!" else echo -e "(Re)Install Ansible..." + $APT_PATH -y remove ansible $BASEDIR/iiab/scripts/ansible fi else From 3e46fab6a9eee1d417ab69197d03692e601671f6 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 17 Sep 2020 17:23:25 +0100 Subject: [PATCH 21/42] invert interactive to optin - for testing whiptail menus --- iiab-upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 338a9183..b5cffe9a 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -18,9 +18,9 @@ MASTER=1 MIN_RPI_KERN=1336 SELFUPDATE_SCRIPT="/tmp/.updateScript.sh" # scrape the command line -if [ "$1" = "--non-interactive" ]; then +if [ "$1" = "--interactive" ]; then shift 1 - INTERACTIVE=0 + INTERACTIVE=1 fi if [ "$1" = "--upgrade" ]; then From b305674265ae8a1953e6eab6a90b7ce4b0769510 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 17 Sep 2020 17:37:07 +0100 Subject: [PATCH 22/42] check_kernel refactor for standalone use --- iiab-upgrade | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index b5cffe9a..3b01761e 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -35,6 +35,20 @@ if [ "$1" = "--reinstall" ]; then REINSTALL="--reinstall" fi +# Verify that Raspbian is running a recent enough kernel. As Raspbian +# kernel 1333 has wifi issues https://github.com/iiab/iiab/issues/2497. +check_kernel(){ +CURR_KERN=`uname -v | awk '{print $1}' | sed -e s'/#//'` +echo "Found Kernel ""$CURR_KERN" +if version_gt $MIN_RPI_KERN $CURR_KERN; then + echo -e "\033[31;5mWARNING: Kernel ""$MIN_RPI_KERN"" or higher required with Raspbian.\033[0m" + echo -e "\033[31;5mPLEASE RUN 'apt update' then 'apt install raspberrypi-kernel' then reboot.\033[0m" + echo -e "\033[31;5mTHEN recheck the kernel version with iiab-upgrade --kernel-check \033[0m" + echo -e "\033[31;5mTHEN IF NEC run 'rpi-update' to install a more recent kernel \033[0m" + echo -e "\033[31;5mPlease check with developers before running the above command" +fi +} + # Subroutines for upgrade logic check_branch(){ git -C $BASEDIR/iiab branch | grep \* | grep release-7 | wc -l @@ -127,6 +141,11 @@ check_user_pwd() { } # start exec here +if [ "$1" = "--kernel-check" ]; then + check_kernel + exit 0 +fi + update_self if [ `check_branch` -gt 0 ]; then @@ -434,21 +453,9 @@ echo -e "global community, learning from other initiatives in your region and be #echo -e "(over Wi-Fi anyway) until you later run 'iiab-hotspot-off'. CAVEAT: these" #echo -e "two commands only work with Raspberry Pi as of 2019-09-30.\n" -# Verify that Raspbian is running a recent enough kernel. As Raspbian -# kernel 1333 has wifi issues https://github.com/iiab/iiab/issues/2497. -CURR_KERN=`uname -v | awk '{print $1}' | sed -e s'/#//'` -echo "Found Kernel ""$CURR_KERN" -if [ -f /etc/rpi-issue ] && version_gt $MIN_RPI_KERN $CURR_KERN; then - echo -e "\033[31;5mWARNING: Kernel ""$MIN_RPI_KERN"" or higher required with Raspbian.\033[0m" -# echo -e "\033[31;5mPLEASE RUN 'apt update' then 'apt install raspberrypi-kernel' then reboot.\033[0m" - echo -e "\033[31;5mTHEN IF NEC run 'rpi-update' to install a more recent kernel \033[0m" - echo -e "\033[31;5mPlease check with developers before running this command" -# if [ $INTERACTIVE == 1 ]; then -# echo -e "'enter' to continue" -# read ans < /dev/tty -# fi +if [ -f /etc/rpi-issue ]; then + check_kernel fi - # cleanup if [ -f $SELFUPDATE_SCRIPT ]; then rm $SELFUPDATE_SCRIPT From 1de89be012b10f5c9cd67c4e820b0697ebf31f3b Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 17 Sep 2020 15:54:43 +0100 Subject: [PATCH 23/42] update continue warning --- iiab-upgrade | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 3b01761e..daeb92cb 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -257,11 +257,11 @@ fi # F. Mandate OS SECURITY/UPDATES if 'apt update' has any (IF SO REBOOT) # Educate implementer while waiting for 'apt update' -echo -e "\n\n โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" -echo -e " โ–ˆโ–ˆ โ–ˆโ–ˆ" -echo -e " โ–ˆโ–ˆ RUN 'sudo iiab' IF THIS INSTALL SCRIPT EVER FAILS, TO TRY TO CONTINUE! โ–ˆโ–ˆ" -echo -e " โ–ˆโ–ˆ โ–ˆโ–ˆ" -echo -e " โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" +echo -e "\n\n โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆ โ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆ RUN 'sudo iiab-upgrade' IF THIS INSTALL SCRIPT EVER FAILS, TO TRY TO CONTINUE! โ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆ โ–ˆโ–ˆ" +echo -e " โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ" echo -e "\n" if [ $INTERACTIVE == 1 ]; then echo -ne "\nHit [ENTER] to confirm you'll TRY TO RERUN 'sudo iiab' IF THERE IS A PROBLEM: " From e5387f1a96cc2d6c9ce0f3e582e96896b99bce5d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 18 Sep 2020 05:22:37 +0100 Subject: [PATCH 24/42] curl will use interactive mode --- 7.2-install.txt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/7.2-install.txt b/7.2-install.txt index 212e1f2c..0be26373 100644 --- a/7.2-install.txt +++ b/7.2-install.txt @@ -1,31 +1,32 @@ #!/bin/bash +# Copied https://github.com/jvonau/iiab-factory/master/7.2-install.txt +# Copied from: https://github.com/jvonau/iiab-factory/blob/jv-pi-gen/install.txt # Copied from: https://github.com/iiab/iiab-factory/blob/master/install.txt - # To install Internet-in-a-Box (IIAB) 7.2 / pre-release onto Raspberry Pi OS, # Ubuntu 20.04 or Debian 10, run this 1-line installer: # -# curl d.iiab.io/install.txt | sudo bash - -# 1. WARNING: NOOBS IS *NOT* SUPPORTED, as its partitioning is very different. +# curl https://raw.githubusercontent.com/jvonau/iiab-factory/master/7.2-install.txt | sudo bash +# +# 1. WHEN YOU RUN 1-LINE INSTALLER FROM ABOVE +# YOU THEN NEED TO TYPE IN YOUR PASSWORD IF ON UBUNTU/DEBIAN/ETC (for sudo) +# ^^^ ^^^^ ^^^^ ^^ ^^^^ ^^ ^^^^ ^^^^^^^^ +# +# 2. WARNING: NOOBS IS *NOT* SUPPORTED, as its partitioning is very different. # On a Raspberry Pi, WE RECOMMEND YOU INSTALL THE LATEST RASPBERRY PI OS: # https://www.raspberrypi.org/documentation/installation/installing-images/README.md # To attempt IIAB 7.2 on another Linux see the full/manual instructions: # https://github.com/iiab/iiab/wiki/IIAB-Installation#do-everything-from-scratch -# 2. An Ethernet cable is HIGHLY RECOMMENDED during installation, as this is +# 3. An Ethernet cable is HIGHLY RECOMMENDED during installation, as this is # more reliable than Wi-Fi (and faster!) -# 3. Run 'sudo raspi-config' on RPi, to set LOCALISATION OPTIONS +# 4. Run 'sudo raspi-config' on RPi, to set LOCALISATION OPTIONS -# 4. OPTIONAL: if you have slow/pricey Internet, pre-position KA Lite's +# 5. OPTIONAL: if you have slow/pricey Internet, pre-position KA Lite's # mandatory 0.9 GB English Pack (en.zip) within /tmp -- you can grab a copy # from http://pantry.learningequality.org/downloads/ka-lite/0.17/content/contentpacks/en.zip -# 5. WHEN YOU RUN 1-LINE INSTALLER 'curl d.iiab.io/install.txt | sudo bash' -# YOU THEN NEED TO TYPE IN YOUR PASSWORD IF ON UBUNTU/DEBIAN/ETC (for sudo) -# ^^^ ^^^^ ^^^^ ^^ ^^^^ ^^ ^^^^ ^^^^^^^^ - -# 6. Follow on-screen instructions (TYPE 'sudo iiab' TO RESUME IF EVER NECESS!) +# 6. Follow on-screen instructions (TYPE 'sudo iiab-upgrade' TO RESUME IF EVER NECESS!) # 7. About 1-2 hours later, it will announce that INTERNET-IN-A-BOX (IIAB) # SOFTWARE INSTALL IS COMPLETE, prompting you to reboot...TO ADD CONTENT! @@ -41,7 +42,6 @@ # IIAB Development Team # http://FAQ.IIAB.IO -# Copied from: https://github.com/jvonau/iiab-factory/blob/jv-pi-gen/install.txt set -e # Exit on error (avoids snowballing) export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions BASE=/opt/iiab @@ -122,4 +122,4 @@ else fi # Run install script! -/usr/sbin/iiab +/usr/sbin/iiab-upgrade --interactive From 9ac4b64a0dbea9e27b15cc1d71bc9d58968fe17f Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 19 Sep 2020 01:59:53 +0100 Subject: [PATCH 25/42] branch feedback and pull -q --- 7.2-install.txt | 25 +++++++++---------------- iiab-upgrade | 9 ++++----- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/7.2-install.txt b/7.2-install.txt index 0be26373..652ed227 100644 --- a/7.2-install.txt +++ b/7.2-install.txt @@ -79,7 +79,8 @@ if [ -d iiab-factory ]; then echo -e "REPO iiab-factory EXISTS? -- updating master branch" cd iiab-factory git checkout master - git pull + git pull -q + echo -e "Creating branch $BRANCH" git branch -D $BRANCH &> /dev/null || true git checkout -b $BRANCH cp --remove-destination $BASE/iiab-factory/iiab /usr/sbin/iiab @@ -88,6 +89,7 @@ else echo -e "Cloning iiab-factory" git clone https://github.com/iiab/iiab-factory --depth 1 cd iiab-factory + echo -e "Creating branch $BRANCH" git checkout -b $BRANCH cp $BASE/iiab-factory/iiab /usr/sbin/iiab cp $BASE/iiab-factory/iiab-upgrade /usr/sbin/iiab-upgrade @@ -95,30 +97,21 @@ fi cd $BASE echo if [ -d iiab ]; then - echo -e "REPO iiab EXISTS? Consider 'sudo iiab --upgrade'" #FIXME + echo -e "REPO iiab EXISTS?" else cd iiab git clone https://github.com/iiab/iiab --depth 10 --branch master - git checkout -b $BRANCH # this goes -# post branching below -# git clone https://github.com/iiab/iiab --depth 10 --branch $BRANCH -# git checkout -b master -# git config branch.master.remote origin -# git config branch.master.merge refs/heads/master -# git checkout $BRANCH + echo -e "Creating branch $BRANCH" + git checkout -b $BRANCH fi cd $BASE echo if [ -d iiab-admin-console ]; then - echo -e "REPO iiab-admin-console EXISTS? Consider 'sudo iiab --upgrade'" #FIXME + echo -e "REPO iiab-admin-console EXISTS?" else git clone https://github.com/iiab/iiab-admin-console --depth 1 --branch ADMBRANCH - git checkout -b $BRANCH # this goes -# post branching below -# git checkout -b master -# git config branch.master.remote origin -# git config branch.master.merge refs/heads/master -# git checkout $BRANCH + echo -e "Creating branch $BRANCH" + git checkout -b $BRANCH fi # Run install script! diff --git a/iiab-upgrade b/iiab-upgrade index daeb92cb..9570525b 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -77,15 +77,14 @@ function update_master(){ cd iiab echo -e "\nUpdating iiab" git checkout master - git pull - NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $2}') + git pull -q fi cd $BASEDIR if [ -d iiab-admin-console ]; then echo -e "\nUpdating iiab-admin-console" cd iiab-admin-console git checkout master - git pull + git pull -q fi } @@ -108,7 +107,7 @@ function update_self() { echo -e "\nUpdating iiab-factory" cd iiab-factory git checkout master - git pull + git pull -q NEW_VERSION=$(grep RELEASE $SCRIPT | awk -F = '{print $2}' | head -n 1) cp $SCRIPT /usr/sbin/$SCRIPT echo "Latest $SCRIPT now installed" @@ -156,7 +155,7 @@ if [ `check_branch` -gt 0 ]; then echo "remaning on release-7.X branch updating" cd $BASEDIR/iiab MASTER=0 - git pull + git pull -q NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $2}') fi fi From b9f54edf99f40c859b8170e9efdf6e4e32983a6c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 19 Sep 2020 06:28:43 +0100 Subject: [PATCH 26/42] upgrades_roles portability --- iiab-upgrade | 42 +++++++++++++++++++++++++++++++----------- upgrade_roles | 3 +++ upgrade_roles.txt | 12 ++++++++++++ 3 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 upgrade_roles create mode 100644 upgrade_roles.txt diff --git a/iiab-upgrade b/iiab-upgrade index 9570525b..49c4e000 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -3,13 +3,14 @@ set -e # Exit on error (avoids snowballing) export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions SCRIPT=iiab-upgrade -RELEASE=2 +RELEASE=1 CURR_VER="" # Ansible version you currently have installed GOOD_VER="2.10.1" # preferred Ansible version BASEDIR=/opt/iiab CONFDIR=/etc/iiab -IIABENV=$CONFDIR/iiab.env FLAGDIR=$CONFDIR/install-flags +IIABENV=$CONFDIR/iiab.env +IIABSTATE=$CONFDIR/iiab_state.yml APT_PATH=/usr/bin/apt # Avoids problematic /usr/local/bin/apt on Linux Mint REINSTALL="" INTERACTIVE=0 @@ -71,6 +72,21 @@ function use_master(){ fi } +function upgrade_source(){ + # assumes working dir is /opt/iiab/iiab just after the git pull + echo -e "\n checking upgrade source" + if [ -f upgrade_roles ]; then + NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $1}') + upg_path="" + else + echo " still not playing nice" + for REV in $(cat $BASEDIR/iiab-factory/upgrade_roles | awk '{print $1}'); do + NEWREV=$REV + done + upg_path=$BASEDIR/iiab-factory/ + fi +} + function update_master(){ cd $BASEDIR if [ -d iiab ]; then @@ -93,6 +109,7 @@ function check_revision(){ if [ -f $IIABENV ]; then source $IIABENV OLDREV=$IIAB_REVISION + upgrade_source if [ $NEWREV -gt $OLDREV ]; then echo -e "\nNEW IIAB Revison Found\n" UPDATE=1 @@ -156,7 +173,6 @@ if [ `check_branch` -gt 0 ]; then cd $BASEDIR/iiab MASTER=0 git pull -q - NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $2}') fi fi @@ -297,7 +313,10 @@ cat /tmp/apt.stdout # "All packages are up to date.\n" # think version_gt is choking on 2913 vs 2101 with the .'s removed but my 2.10.1 install skipped # ansible correctly when good_ver was 2.9.13. Changed back on the fly to 2.9.13 while live testing # and the install appears to not skip when 2.9.13 == 2.9.13 and we end up with the noted apt error. -if [ $(command -v ansible-playbook) ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd" +if ! [ $(command -v ansible-playbook) ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd" + echo -e "Install Ansible..." + $BASEDIR/iiab/scripts/ansible +else CURR_VER=`ansible --version | head -1 | awk '{print $2}'` # To match iiab-install. Was: CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "` echo -e "\n\nCURRENTLY INSTALLED ANSIBLE: $CURR_VER" if version_gt $CURR_VER $GOOD_VER || [ $CURR_VER == $GOOD_VER ]; then @@ -307,9 +326,6 @@ if [ $(command -v ansible-playbook) ]; then # "command -v" is POSIX compliant $APT_PATH -y remove ansible $BASEDIR/iiab/scripts/ansible fi -else - echo -e "Install Ansible..." - $BASEDIR/iiab/scripts/ansible fi @@ -335,8 +351,8 @@ echo -e "โ”‚ child script ./iiab-install -- both avoid repeating any of the 9 echo -e "โ”‚ โ”‚" echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" cd $BASEDIR/iiab/ -if [ -f upgrade_roles ] && [ $UPDATE == 1 ]; then - for REV in $(cat upgrade_roles | awk '{print $1}'); do +if [ $UPDATE == 1 ]; then + for REV in $(cat $upg_path/upgrade_roles | awk '{print $1}'); do if [ $REV -gt $OLDREV ]; then echo "found REV $REV - OLDREV $OLDREV" force=$(grep $REV upgrade_roles | awk '{print $2}') @@ -348,13 +364,17 @@ if [ -f upgrade_roles ] && [ $UPDATE == 1 ]; then elif [ "$force" == "osm-vector-maps" ]; then # role directory & installed marker differ force=osm_vector_maps else - echo "no role execptions found" + echo "no mismatch" fi echo -e "\nREV has $force - removing from iiab_state.yml" - sed -i "/^$force/d" $CONFDIR/iiab_state.yml + sed -i "/^$force/d" $IIABSTATE fi done ./iiab-configure + if ! [ -f upgrade_roles ]; then + echo "manually update $IIABENV with IIAB_REVISION while 2500 is sidelined" + sed -i "s/^IIAB_REVISION=.*/IIAB_REVISION=$NEWREV/" $IIABENV + fi else ./iiab-install $REINSTALL fi diff --git a/upgrade_roles b/upgrade_roles new file mode 100644 index 00000000..9dc453c2 --- /dev/null +++ b/upgrade_roles @@ -0,0 +1,3 @@ +1 osm_vector_maps +2 gitea +3 lokole diff --git a/upgrade_roles.txt b/upgrade_roles.txt new file mode 100644 index 00000000..c7790b09 --- /dev/null +++ b/upgrade_roles.txt @@ -0,0 +1,12 @@ +# since there are really only two files in play don't depend on 2500 being in place +# tagged https://github.com/iiab/iiab/releases/tag/7.1.5-premap +# git 5d64c066627f664d2a20da50d4a249c3ca87529a as 0 revision stating point +# https://github.com/holta/iiab/compare/5GHz-warning-with-dual-wifi...iiab:master + +# pbx was non-installable prior to #2489 - no upgrade need +# #2515 would need a pass through the network role via ./iiab-network or ICO +1 osm-vector-maps #2487 +# mongodb #2487 #2584: bugfix for 64bit debian - upgrade on 64bit ubuntu +# - no change for 32bit OSs +2 gitea #2504 +3 lokole #2514 From ef09ab106291a563879661193bce48f5ee0a5273 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 19 Sep 2020 15:51:34 +0100 Subject: [PATCH 27/42] check for root - user feedback --- 7.2-install.txt | 7 +++++++ iiab-upgrade | 30 +++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/7.2-install.txt b/7.2-install.txt index 652ed227..56a650ae 100644 --- a/7.2-install.txt +++ b/7.2-install.txt @@ -70,6 +70,13 @@ case $OS_VER in ;; esac +# Everything else needs to be run as root +if [ $(id -u) -ne 0 ]; then + echo -e "$SCRIPT must be run as root. Try 'sudo $SCRIPT'\n" + exit 1 +fi + + echo -e "\n\nDOWNLOAD (CLONE) IIAB'S 3 KEY REPOS INTO $BASE ...\n" /usr/bin/apt -y install git nano whiptail mkdir -p $BASE diff --git a/iiab-upgrade b/iiab-upgrade index 49c4e000..2bf67d0c 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -18,6 +18,7 @@ UPDATE=0 MASTER=1 MIN_RPI_KERN=1336 SELFUPDATE_SCRIPT="/tmp/.updateScript.sh" + # scrape the command line if [ "$1" = "--interactive" ]; then shift 1 @@ -43,13 +44,24 @@ CURR_KERN=`uname -v | awk '{print $1}' | sed -e s'/#//'` echo "Found Kernel ""$CURR_KERN" if version_gt $MIN_RPI_KERN $CURR_KERN; then echo -e "\033[31;5mWARNING: Kernel ""$MIN_RPI_KERN"" or higher required with Raspbian.\033[0m" - echo -e "\033[31;5mPLEASE RUN 'apt update' then 'apt install raspberrypi-kernel' then reboot.\033[0m" + echo -e "\033[31;5mPLEASE RUN 'sudo apt update' then 'sudo apt install raspberrypi-kernel' then reboot.\033[0m" echo -e "\033[31;5mTHEN recheck the kernel version with iiab-upgrade --kernel-check \033[0m" - echo -e "\033[31;5mTHEN IF NEC run 'rpi-update' to install a more recent kernel \033[0m" - echo -e "\033[31;5mPlease check with developers before running the above command" + echo -e "\033[31;5mPlease check with developers before running the below command" + echo -e "\033[31;5mTHEN IF NEC run 'sudo rpi-update' to install a more recent kernel \033[0m" fi } +if [ "$1" = "--kernel-check" ]; then + check_kernel + exit 0 +fi + +# Everything else needs to be run as root +if [ $(id -u) -ne 0 ]; then + echo -e "$SCRIPT must be run as root. Try 'sudo $SCRIPT'\n" + exit 1 +fi + # Subroutines for upgrade logic check_branch(){ git -C $BASEDIR/iiab branch | grep \* | grep release-7 | wc -l @@ -104,7 +116,6 @@ function update_master(){ fi } - function check_revision(){ if [ -f $IIABENV ]; then source $IIABENV @@ -157,11 +168,6 @@ check_user_pwd() { } # start exec here -if [ "$1" = "--kernel-check" ]; then - check_kernel - exit 0 -fi - update_self if [ `check_branch` -gt 0 ]; then @@ -343,11 +349,9 @@ fi echo -e "\nโ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”" echo -e "โ”‚ โ”‚" -echo -e "โ”‚ NOW INSTALL IIAB SOFTWARE! If glitches arise (connectivity or otherwise) โ”‚" -echo -e "โ”‚ โ”‚" -echo -e "โ”‚ PLEASE TRY TO CONTINUE BY RE-RUNNING PARENT SCRIPT 'sudo iiab' -- or run โ”‚" +echo -e "โ”‚ NOW UPGRADE IIAB SOFTWARE! If glitches arise (connectivity or otherwise) โ”‚" echo -e "โ”‚ โ”‚" -echo -e "โ”‚ child script ./iiab-install -- both avoid repeating any of the 9 stages. โ”‚" +echo -e "โ”‚ PLEASE TRY TO CONTINUE BY RE-RUNNING SCRIPT 'sudo iiab-upgrade' โ”‚" echo -e "โ”‚ โ”‚" echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" cd $BASEDIR/iiab/ From 7db3399c8c845135f1e078d282a076b1cf678c84 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 20 Sep 2020 07:36:05 +0100 Subject: [PATCH 28/42] pi-gen test --- iiab-upgrade | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iiab-upgrade b/iiab-upgrade index 2bf67d0c..1ae2c698 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -16,6 +16,8 @@ REINSTALL="" INTERACTIVE=0 UPDATE=0 MASTER=1 +TEST=jv +IIABTEST=provision MIN_RPI_KERN=1336 SELFUPDATE_SCRIPT="/tmp/.updateScript.sh" @@ -106,6 +108,10 @@ function update_master(){ echo -e "\nUpdating iiab" git checkout master git pull -q + if ! [ x$IIABTEST == "x" ]; then + git checkout -b $IIABTEST + git pull -q https://github.com/jvonau/iiab.git $IIABTEST + fi fi cd $BASEDIR if [ -d iiab-admin-console ]; then From c8867c01217f922c6b20dd7377737a6e821934c5 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 20 Sep 2020 08:08:34 +0100 Subject: [PATCH 29/42] upgrades are at stage 9 --- iiab-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iiab-upgrade b/iiab-upgrade index 1ae2c698..ec33f493 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -127,7 +127,7 @@ function check_revision(){ source $IIABENV OLDREV=$IIAB_REVISION upgrade_source - if [ $NEWREV -gt $OLDREV ]; then + if [ $NEWREV -gt $OLDREV ] && [ $STAGE -eq 9 ]; then echo -e "\nNEW IIAB Revison Found\n" UPDATE=1 fi From af821e6677549ecdfe77f8903f19c2d07014bf38 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 24 Sep 2020 05:06:04 +0100 Subject: [PATCH 30/42] non-interactive skip iiab-admin creation --- iiab-upgrade | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index ec33f493..2edcf0c6 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -188,26 +188,24 @@ if [ `check_branch` -gt 0 ]; then fi fi -# B. Ask for password change if pi/raspberry default remains -if check_user_pwd "pi" "raspberry"; then - if [ $INTERACTIVE == 1 ]; then +if [ $INTERACTIVE == 1 ]; then + # B. Ask for password change if pi/raspberry default remains + if check_user_pwd "pi" "raspberry"; then PASSWORD=$(whiptail --passwordbox " Raspberry Pi's are COMPROMISED often if the default password is not changed! What password do you want for GNU/Linux user 'pi' ? press [Enter] for no change " 12 78 --title "password dialog" 3>&1 1>&2 2>&3) echo pi:$PASSWORD | chpasswd 2>&1 > /dev/null || true # Overrides 'set -e' fi -fi -# C. Create user 'iiab-admin' as nec, with default password -if ! id -u iiab-admin > /dev/null 2> /dev/null; then - useradd iiab-admin - echo iiab-admin:g0adm1n | chpasswd -fi + # C. Create user 'iiab-admin' as nec, with default password + if ! id -u iiab-admin > /dev/null 2> /dev/null; then + useradd iiab-admin + echo iiab-admin:g0adm1n | chpasswd + fi -# D. Ask for password change if iiab-admin/g0adm1n default remains -if check_user_pwd "iiab-admin" "g0adm1n"; then - if [ $INTERACTIVE == 1 ]; then + if check_user_pwd "iiab-admin" "g0adm1n"; then + # D. Ask for password change if iiab-admin/g0adm1n default remains PASSWORD2=$(whiptail --passwordbox " User 'iiab-admin' retains default password 'g0adm1n' per http://FAQ.IIAB.IO This is for login to Internet-in-a-Box's Admin Console (http://box.lan/admin) From 090b2c9cd3c87d03c9e8eb4a6922d38c51edd497 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 24 Sep 2020 05:10:43 +0100 Subject: [PATCH 31/42] non-interactive skip bittorrent start --- iiab-upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iiab-upgrade b/iiab-upgrade index 2edcf0c6..091e3142 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -440,7 +440,7 @@ fi # OLD WAY ABOVE - fails w/ sev ISPs per https://github.com/iiab/iiab/issues/871 # K. Start BitTorrent downloads, e.g. if $CONFDIR/local_vars.yml requested any -if (systemctl -q is-active transmission-daemon) then +if [ $INTERACTIVE == 1 ] && (systemctl -q is-active transmission-daemon) then echo -e "\n\nSTARTING BITTORRENT DOWNLOAD(S) for KA Lite...Please Monitor: http://box:9091\n" transmission-remote -n Admin:changeme -t all --start fi From 49af93505dd101c2063fc39dec5d4cba24f74511 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 24 Sep 2020 05:19:12 +0100 Subject: [PATCH 32/42] update iiab branch and repo --- iiab-upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 091e3142..357ff87b 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -17,7 +17,7 @@ INTERACTIVE=0 UPDATE=0 MASTER=1 TEST=jv -IIABTEST=provision +IIABTEST=iiab-ng-7.2 MIN_RPI_KERN=1336 SELFUPDATE_SCRIPT="/tmp/.updateScript.sh" @@ -110,7 +110,7 @@ function update_master(){ git pull -q if ! [ x$IIABTEST == "x" ]; then git checkout -b $IIABTEST - git pull -q https://github.com/jvonau/iiab.git $IIABTEST + git pull -q https://github.com/jvonau/IIAB-NG.git $IIABTEST fi fi cd $BASEDIR From b517e4ccc012399e1e9a408c2d0166d04e28253c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 26 Sep 2020 04:58:14 +0100 Subject: [PATCH 33/42] bump upgrade_roles --- upgrade_roles | 2 ++ upgrade_roles.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/upgrade_roles b/upgrade_roles index 9dc453c2..38372686 100644 --- a/upgrade_roles +++ b/upgrade_roles @@ -1,3 +1,5 @@ 1 osm_vector_maps 2 gitea 3 lokole +4 sugarizer +5 mediawiki diff --git a/upgrade_roles.txt b/upgrade_roles.txt index c7790b09..f6c8877d 100644 --- a/upgrade_roles.txt +++ b/upgrade_roles.txt @@ -10,3 +10,5 @@ # - no change for 32bit OSs 2 gitea #2504 3 lokole #2514 +4 sugarizer #2543 +5 mediawiki #2547 From 07a9f790ea15774020857280655dad30057f9dc5 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 26 Sep 2020 05:01:00 +0100 Subject: [PATCH 34/42] test branch delete --- iiab-upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/iiab-upgrade b/iiab-upgrade index 357ff87b..7f2febd4 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -109,6 +109,7 @@ function update_master(){ git checkout master git pull -q if ! [ x$IIABTEST == "x" ]; then + git branch -D $IIABTEST || true git checkout -b $IIABTEST git pull -q https://github.com/jvonau/IIAB-NG.git $IIABTEST fi From 5c216e62d008e34d554f565a216725251219c26f Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 30 Sep 2020 06:30:51 +0100 Subject: [PATCH 35/42] don't 'tunefs' in non-interactive - like second pass though 'iiab' but skipped --- iiab-upgrade | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 7f2febd4..acfdc199 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -90,10 +90,11 @@ function upgrade_source(){ # assumes working dir is /opt/iiab/iiab just after the git pull echo -e "\n checking upgrade source" if [ -f upgrade_roles ]; then + echo " IIAB playing nice" NEWREV=$(grep iiab_revision vars/default_vars.yml | awk '{print $1}') upg_path="" else - echo " still not playing nice" + echo " IIAB still not playing nice" for REV in $(cat $BASEDIR/iiab-factory/upgrade_roles | awk '{print $1}'); do NEWREV=$REV done @@ -344,7 +345,7 @@ fi # G. If RPi, lower reserve disk space from ~5% to 1% #if [ -f /proc/device-tree/model ] && grep -qi raspberry /proc/device-tree/model; then -if [ -e /dev/mmcblk0p2 ]; then +if [ $INTERACTIVE == 1 ] && [ -e /dev/mmcblk0p2 ]; then echo -e "\n\nFound microSD card /dev/mmcblk0p2: Lower its reserve disk space from ~5% to 1%\n" tune2fs -m 1 /dev/mmcblk0p2 fi From a0a8c05d096e22f91018a11b976cd7bfbcc5713f Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 12 Oct 2020 19:29:43 +0100 Subject: [PATCH 36/42] upgrade updates --- iiab-upgrade | 2 +- upgrade_roles | 4 ++++ upgrade_roles.txt | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/iiab-upgrade b/iiab-upgrade index acfdc199..ef968b1a 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -5,7 +5,7 @@ export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions SCRIPT=iiab-upgrade RELEASE=1 CURR_VER="" # Ansible version you currently have installed -GOOD_VER="2.10.1" # preferred Ansible version +GOOD_VER="2.10.1" # Trigger point for anisble forced reinstall BASEDIR=/opt/iiab CONFDIR=/etc/iiab FLAGDIR=$CONFDIR/install-flags diff --git a/upgrade_roles b/upgrade_roles index 38372686..dc8c5099 100644 --- a/upgrade_roles +++ b/upgrade_roles @@ -3,3 +3,7 @@ 3 lokole 4 sugarizer 5 mediawiki +6 kolibri +7 gitea +8 phpMyAdmin +9 sugarizer diff --git a/upgrade_roles.txt b/upgrade_roles.txt index f6c8877d..f8b45dff 100644 --- a/upgrade_roles.txt +++ b/upgrade_roles.txt @@ -12,3 +12,7 @@ 3 lokole #2514 4 sugarizer #2543 5 mediawiki #2547 +6 kolibri #2555 actually is "latest deb" moving 14.2 -> 14.3 +7 gitea #2554 +8 phpMyAdmin #2568 +9 sugarizer #2569 From 37edfb5e2b2b19de97c6146137e5219bda95d4ba Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 12 Oct 2020 21:02:33 +0100 Subject: [PATCH 37/42] add logic for admin_console_install & admin_console_enabled --- iiab-upgrade | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index ef968b1a..c718b1d3 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -390,13 +390,24 @@ else fi echo -e "Install Admin Console... (also runs iiab-get-kiwix-cat to d/l Kiwix catalog, and installs Dynamic Menuing for /library/www/html/home/index.html)\n" -if [ ! -f $FLAGDIR/iiab-admin-console-complete ] || [ $UPDATE == 1 ]; then - cd $BASEDIR/iiab-admin-console - ./install - touch $FLAGDIR/iiab-admin-console-complete +if ! grep -q '^admin_console_install:\s\+[fF]alse\b' /etc/iiab/local_vars.yml ; then + if [ ! -f $FLAGDIR/iiab-admin-console-complete ] || [ $UPDATE == 1 ]; then + cd $BASEDIR/iiab-admin-console + ./install + touch $FLAGDIR/iiab-admin-console-complete + else + echo -e "ADMIN CONSOLE INSTALLATION IS ALREADY COMPLETE -- per existence of:" + echo -e "$FLAGDIR/iiab-admin-console-complete\n" + fi + if grep -q '^admin_console_enabled: False' /etc/iiab/local_vars.yml ; then + echo -e "'admin_console_enabled: False' is in /etc/iiab/local_vars.yml" + echo -e "...so let's try to DISABLE & STOP Admin Console's iiab-cmdsrv.service" + systemctl disable iiab-cmdsrv + systemctl stop iiab-cmdsrv + fi else - echo -e "ADMIN CONSOLE INSTALLATION IS ALREADY COMPLETE -- per existence of:" - echo -e "$FLAGDIR/iiab-admin-console-complete\n" + echo -e "LET'S NOT TRY TO INSTALL ADMIN CONSOLE -- because:" + echo -e "'admin_console_install: False' is in /etc/iiab/local_vars.yml\n" fi # J. KA Lite prep @@ -414,7 +425,7 @@ if [ -d /library/ka-lite ]; then echo -e "$FLAGDIR/kalite-zone-complete\n" fi - echo -e "\nInstall KA Lite's mandatory 0.9 GB English Pack... (en.zip)\n" + echo -e "\nInstall KA Lite's mandatory 0.9 GB English Pack... en.zip\n" if [ ! -f $FLAGDIR/kalite-en.zip-complete ]; then #echo -e 'Now retrieving it...\n' cd /tmp @@ -442,7 +453,7 @@ fi # OLD WAY ABOVE - fails w/ sev ISPs per https://github.com/iiab/iiab/issues/871 # K. Start BitTorrent downloads, e.g. if $CONFDIR/local_vars.yml requested any -if [ $INTERACTIVE == 1 ] && (systemctl -q is-active transmission-daemon) then +if [ $INTERACTIVE == 1 ] && (systemctl -q is-active transmission-daemon); then echo -e "\n\nSTARTING BITTORRENT DOWNLOAD(S) for KA Lite...Please Monitor: http://box:9091\n" transmission-remote -n Admin:changeme -t all --start fi From 53a5b74a8e72b66d14a073b81835ae2dde040c55 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 14 Oct 2020 15:24:23 +0100 Subject: [PATCH 38/42] add some cheap metrics --- iiab-upgrade | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index c718b1d3..ab9e4d8a 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -176,7 +176,9 @@ check_user_pwd() { } # start exec here +T_Start=`date` update_self +T_self=`date` if [ `check_branch` -gt 0 ]; then if whiptail --yesno "\nFound release-7.X branch would you like (re)install using the latest master?" 20 60 2 3>&1 1>&2 2>&3; then @@ -221,7 +223,7 @@ if [ $MASTER == 1 ]; then update_master fi check_revision - +T_check=`date` if [ -f $FLAGDIR/iiab-complete ] && [ $UPDATE == 0 ]; then echo -e "\n\nIIAB INSTALLATION (/usr/sbin/iiab) IS ALREADY COMPLETE -- per existence of:" echo -e "$FLAGDIR/iiab-complete -- nothing to do.\n" @@ -321,7 +323,7 @@ elif grep -q 'apt list --upgradable' /tmp/apt.stdout; then # apt.stdout typic fi fi cat /tmp/apt.stdout # "All packages are up to date.\n" - +T_apt=`date` # think version_gt is choking on 2913 vs 2101 with the .'s removed but my 2.10.1 install skipped # ansible correctly when good_ver was 2.9.13. Changed back on the fly to 2.9.13 while live testing # and the install appears to not skip when 2.9.13 == 2.9.13 and we end up with the noted apt error. @@ -339,7 +341,7 @@ else $BASEDIR/iiab/scripts/ansible fi fi - +T_ansible=`date` ######################### INTERACTIVE STUFF IS ABOVE ######################### @@ -388,7 +390,7 @@ if [ $UPDATE == 1 ]; then else ./iiab-install $REINSTALL fi - +T_iiab=`date` echo -e "Install Admin Console... (also runs iiab-get-kiwix-cat to d/l Kiwix catalog, and installs Dynamic Menuing for /library/www/html/home/index.html)\n" if ! grep -q '^admin_console_install:\s\+[fF]alse\b' /etc/iiab/local_vars.yml ; then if [ ! -f $FLAGDIR/iiab-admin-console-complete ] || [ $UPDATE == 1 ]; then @@ -409,7 +411,7 @@ else echo -e "LET'S NOT TRY TO INSTALL ADMIN CONSOLE -- because:" echo -e "'admin_console_install: False' is in /etc/iiab/local_vars.yml\n" fi - +T_console=`date` # J. KA Lite prep if [ -d /library/ka-lite ]; then echo -e "\n\nKA LITE REQUIRES 2 THINGS...\n" @@ -446,6 +448,7 @@ if [ -d /library/ka-lite ]; then echo -e 'kalite zip already done' fi fi +T_kalite=`date` # WARNING: /tmp/en.zip (and all stuff in /tmp) is auto-deleted during reboots # NEW WAY ABOVE - since 2018-07-03 - installs KA Lite's mandatory English Pack # @@ -500,6 +503,17 @@ fi if [ -f $SELFUPDATE_SCRIPT ]; then rm $SELFUPDATE_SCRIPT fi +T_End=`date` +echo "iiab-upgrade run start: $T_Start" +echo "time to self update: $T_self" +echo "time to revision check: $T_check" +echo "time to apt upgrade: $T_apt" +echo "time to ansible: $T_ansible" +echo "time to iiab: $T_iiab" +echo "time to admin-console $T_console" +echo "time to kailte config: $T_kalite" +echo "iiab-upgrade run end: $T_End" + if [ $INTERACTIVE == 1 ]; then echo -ne "HIT [Y] [Enter] TO REBOOT, [Enter] to exit, CONFIRMING YOU'VE" '"photographed" THE ABOVE PARAGRAPHS: ' ans=n From 33deb8cc820e886551b4b3f46942adaa039bc7f5 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 3 Nov 2020 20:35:28 +0000 Subject: [PATCH 39/42] latest round of changes --- iiab-upgrade | 8 ++++++++ upgrade_roles | 2 ++ upgrade_roles.txt | 3 +++ 3 files changed, 13 insertions(+) diff --git a/iiab-upgrade b/iiab-upgrade index ab9e4d8a..349e5019 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -382,6 +382,14 @@ if [ $UPDATE == 1 ]; then sed -i "/^$force/d" $IIABSTATE fi done + + if [ $OLDREV -lt 10 ]; then + ./runrole www_base + fi + + if [ -f /etc/systemd/system/udev-reload ]; then + systemctl disable udev-reload + fi ./iiab-configure if ! [ -f upgrade_roles ]; then echo "manually update $IIABENV with IIAB_REVISION while 2500 is sidelined" diff --git a/upgrade_roles b/upgrade_roles index dc8c5099..7aef8627 100644 --- a/upgrade_roles +++ b/upgrade_roles @@ -7,3 +7,5 @@ 7 gitea 8 phpMyAdmin 9 sugarizer +11 nodejs +12 diff --git a/upgrade_roles.txt b/upgrade_roles.txt index f8b45dff..7329d844 100644 --- a/upgrade_roles.txt +++ b/upgrade_roles.txt @@ -16,3 +16,6 @@ 7 gitea #2554 8 phpMyAdmin #2568 9 sugarizer #2569 +10 www_base #2581 #2583 for osm +11 nodejs #2606 Node.js 12.x -> 14.x +12 udev #2607 drop udev-restart handle via iiab-upgrade script From db8f6b3e2136cd253b36b4b98df4127b1af7af0d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 4 Nov 2020 01:17:35 +0000 Subject: [PATCH 40/42] should be good to go --- iiab-upgrade | 25 ++++++++++++++----------- upgrade_roles | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 349e5019..7fb706c8 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -3,7 +3,7 @@ set -e # Exit on error (avoids snowballing) export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions SCRIPT=iiab-upgrade -RELEASE=1 +RELEASE=3 CURR_VER="" # Ansible version you currently have installed GOOD_VER="2.10.1" # Trigger point for anisble forced reinstall BASEDIR=/opt/iiab @@ -17,7 +17,8 @@ INTERACTIVE=0 UPDATE=0 MASTER=1 TEST=jv -IIABTEST=iiab-ng-7.2 +#IIABTEST=iiab-ng-7.2 +IIABTEST="" MIN_RPI_KERN=1336 SELFUPDATE_SCRIPT="/tmp/.updateScript.sh" @@ -364,24 +365,26 @@ echo -e "โ”‚ echo -e "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜" cd $BASEDIR/iiab/ if [ $UPDATE == 1 ]; then - for REV in $(cat $upg_path/upgrade_roles | awk '{print $1}'); do - if [ $REV -gt $OLDREV ]; then - echo "found REV $REV - OLDREV $OLDREV" - force=$(grep $REV upgrade_roles | awk '{print $2}') - echo "REV has $force" + echo "upg_path is $upg_path" + echo "OLDREV is $OLDREV" + input="$upg_path/upgrade_roles" + while IFS= read -r REV + do + echo "REV is $REV" + if [ $(echo $REV | awk '{print $1}') -gt $OLDREV ]; then + echo "found REV $REV" + force=$(echo $REV | awk '{print $2}') if [ "$force" == "calibre-web" ]; then # role directory & installed marker differ force=calibreweb elif [ "$force" == "httpd" ]; then # role directory & installed marker differ force=apache elif [ "$force" == "osm-vector-maps" ]; then # role directory & installed marker differ force=osm_vector_maps - else - echo "no mismatch" fi - echo -e "\nREV has $force - removing from iiab_state.yml" + echo -e "REV has $force - removing from iiab_state.yml\\n" sed -i "/^$force/d" $IIABSTATE fi - done + done < "$input" if [ $OLDREV -lt 10 ]; then ./runrole www_base diff --git a/upgrade_roles b/upgrade_roles index 7aef8627..69e57e3f 100644 --- a/upgrade_roles +++ b/upgrade_roles @@ -8,4 +8,4 @@ 8 phpMyAdmin 9 sugarizer 11 nodejs -12 +12 udev From c1ba82f86408101566a391e12ed49a5245ad432d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 4 Nov 2020 04:12:17 +0000 Subject: [PATCH 41/42] more updates --- upgrade_roles | 2 ++ upgrade_roles.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/upgrade_roles b/upgrade_roles index 69e57e3f..36aafafb 100644 --- a/upgrade_roles +++ b/upgrade_roles @@ -9,3 +9,5 @@ 9 sugarizer 11 nodejs 12 udev +13 mongodb +14 kiwix diff --git a/upgrade_roles.txt b/upgrade_roles.txt index 7329d844..46a3bbbe 100644 --- a/upgrade_roles.txt +++ b/upgrade_roles.txt @@ -19,3 +19,5 @@ 10 www_base #2581 #2583 for osm 11 nodejs #2606 Node.js 12.x -> 14.x 12 udev #2607 drop udev-restart handle via iiab-upgrade script +13 mongodb #2613 +14 kiwix #2615 From f1a35ffc0d118cc6557b540606b2981e054e848e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 4 Nov 2020 04:16:05 +0000 Subject: [PATCH 42/42] bump release --- iiab-upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iiab-upgrade b/iiab-upgrade index 7fb706c8..3b1021ca 100755 --- a/iiab-upgrade +++ b/iiab-upgrade @@ -3,7 +3,7 @@ set -e # Exit on error (avoids snowballing) export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions SCRIPT=iiab-upgrade -RELEASE=3 +RELEASE=4 CURR_VER="" # Ansible version you currently have installed GOOD_VER="2.10.1" # Trigger point for anisble forced reinstall BASEDIR=/opt/iiab @@ -131,7 +131,7 @@ function check_revision(){ OLDREV=$IIAB_REVISION upgrade_source if [ $NEWREV -gt $OLDREV ] && [ $STAGE -eq 9 ]; then - echo -e "\nNEW IIAB Revison Found\n" + echo -e "\nNEW IIAB Revison $NEWREV Found\n" UPDATE=1 fi fi