1- #! /bin/bash
1+ #! /usr/bin/env bash
2+
3+ # version - MUST be exactly 7 characters!
4+ UPDATE=" 2024v02"
25
36echo " "
4- echo " _____ ____ _______ _ _ "
5- echo " |_ _/ __ \\ __ __|| | installer | | "
7+ echo " _____ ____ _______ _ installer _ "
8+ echo " |_ _/ __ \\ __ __|| | $UPDATE | | "
69echo " | || | | | | |___| |_ __ _ ___| | __"
710echo " | || | | | | / __| __/ _\` |/ __| |/ /"
811echo " _| || |__| | | \\ __ \\ || (_| | (__| < "
@@ -21,18 +24,12 @@ echo " "
2124# overuse of sudo is a very common problem among new IOTstack users
2225[ " $EUID " -eq 0 ] && echo " This script should NOT be run using sudo" && exit 1
2326
24- # the name of this script is
25- SCRIPT=$( basename " $0 " )
26-
2727# this script should be run without arguments
28- [ $# -ne 0 ] && echo " $SCRIPT parameter (s) $@ ignored"
28+ [ $# -ne 0 ] && echo " command line argument (s) $@ ignored"
2929
3030# assumption(s) which can be overridden
3131IOTSTACK=${IOTSTACK:- " $HOME /IOTstack" }
3232
33- # form absolute path
34- IOTSTACK=$( realpath " $IOTSTACK " )
35-
3633# derived path(s) - note that the menu knows about most of these so
3734# they can't just be changed without a lot of care.
3835IOTSTACK_ENV=" $IOTSTACK /.env"
@@ -113,7 +110,10 @@ function handle_exit() {
113110 [ -d " $IOTSTACK " ] && echo " $1 " > " $IOTSTACK_INSTALLER_HINT "
114111
115112 # inform the user
116- echo -n " $SCRIPT completed"
113+ echo -n " install.sh completed"
114+
115+ # advise if should be re-run
116+ [ $1 -ne 0 ] && echo -n " - but should be re-run"
117117
118118 # reboot takes precedence over logout
119119 if [ " $REBOOT_REQUIRED " = " true" ] ; then
@@ -123,7 +123,16 @@ function handle_exit() {
123123 elif [ " $LOGOUT_REQUIRED " = " true" ] ; then
124124 echo " - a logout is required."
125125 sleep 2
126- kill -HUP " $PPID "
126+ # iterate ancestor processes
127+ for ANCESTOR in $( ps -o ppid=) ; do
128+ # find first process belonging to current user
129+ if [ " $( ps -p $ANCESTOR -o user=) " = " $USER " ] ; then
130+ # kill it
131+ kill -HUP $ANCESTOR
132+ fi
133+ done
134+ # should not reach this
135+ sleep 2
127136 fi
128137
129138 # exit as instructed
@@ -229,13 +238,6 @@ echo ""
229238# is in the expected location, the necessary symlink can be created by
230239# this script and then docker-compose will be installed "correctly".
231240
232- function is_running_OS_release() {
233- unset VERSION_CODENAME
234- [ -f " /etc/os-release" ] && eval $( grep " ^VERSION_CODENAME=" /etc/os-release)
235- [ " $VERSION_CODENAME " = " $1 " ] && return 0
236- return 1
237- }
238-
239241function is_python_script() {
240242 [ $( file -b " $1 " | grep -c " ^Python script" ) -gt 0 ] && return 0
241243 return 1
@@ -305,13 +307,9 @@ else
305307 echo " having installed docker and docker-compose without using the official"
306308 echo " 'convenience script'. You may be able to solve this problem by running"
307309 if is_python_script " $COMPOSE_CMD_PATH " ; then
308- if is_running_OS_release bookworm ; then
309- echo " \$ pip3 uninstall -y --break-system-packages docker-compose"
310- echo " \$ sudo pip3 uninstall -y --break-system-packages docker-compose"
311- else
312- echo " \$ pip3 uninstall -y docker-compose"
313- echo " \$ sudo pip3 uninstall -y docker-compose"
314- fi
310+ echo " \$ export PIP_BREAK_SYSTEM_PACKAGES=1"
311+ echo " \$ pip3 uninstall -y docker-compose"
312+ echo " \$ sudo pip3 uninstall -y docker-compose"
315313 echo " (ignore any errors from those commands)"
316314 else
317315 echo " \$ sudo apt purge -y docker-compose"
384382# implement menu requirements
385383if [ -e " $IOTSTACK_MENU_REQUIREMENTS " ] ; then
386384 echo -e " \nChecking and updating IOTstack dependencies (pip)"
387- unset PYTHON_OPTIONS
388- if is_running_OS_release bookworm ; then
389- echo " Note: pip3 installs bypass externally-managed environment check"
390- PYTHON_OPTIONS=" --break-system-packages"
391- fi
392- pip3 install -U $PYTHON_OPTIONS -r " $IOTSTACK_MENU_REQUIREMENTS "
385+ echo " Note: pip3 installs bypass externally-managed environment check"
386+ PIP_BREAK_SYSTEM_PACKAGES=1 pip3 install -U -r " $IOTSTACK_MENU_REQUIREMENTS "
393387fi
394388
395389# trigger re-creation of venv on next menu launch. Strictly speaking,
0 commit comments