1
- #! /bin/bash
1
+ #! /usr/bin/env bash
2
+
3
+ # version - MUST be exactly 7 characters!
4
+ UPDATE=" 2024v02"
2
5
3
6
echo " "
4
- echo " _____ ____ _______ _ _ "
5
- echo " |_ _/ __ \\ __ __|| | installer | | "
7
+ echo " _____ ____ _______ _ installer _ "
8
+ echo " |_ _/ __ \\ __ __|| | $UPDATE | | "
6
9
echo " | || | | | | |___| |_ __ _ ___| | __"
7
10
echo " | || | | | | / __| __/ _\` |/ __| |/ /"
8
11
echo " _| || |__| | | \\ __ \\ || (_| | (__| < "
@@ -21,18 +24,12 @@ echo " "
21
24
# overuse of sudo is a very common problem among new IOTstack users
22
25
[ " $EUID " -eq 0 ] && echo " This script should NOT be run using sudo" && exit 1
23
26
24
- # the name of this script is
25
- SCRIPT=$( basename " $0 " )
26
-
27
27
# this script should be run without arguments
28
- [ $# -ne 0 ] && echo " $SCRIPT parameter (s) $@ ignored"
28
+ [ $# -ne 0 ] && echo " command line argument (s) $@ ignored"
29
29
30
30
# assumption(s) which can be overridden
31
31
IOTSTACK=${IOTSTACK:- " $HOME /IOTstack" }
32
32
33
- # form absolute path
34
- IOTSTACK=$( realpath " $IOTSTACK " )
35
-
36
33
# derived path(s) - note that the menu knows about most of these so
37
34
# they can't just be changed without a lot of care.
38
35
IOTSTACK_ENV=" $IOTSTACK /.env"
@@ -113,7 +110,10 @@ function handle_exit() {
113
110
[ -d " $IOTSTACK " ] && echo " $1 " > " $IOTSTACK_INSTALLER_HINT "
114
111
115
112
# 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"
117
117
118
118
# reboot takes precedence over logout
119
119
if [ " $REBOOT_REQUIRED " = " true" ] ; then
@@ -123,7 +123,16 @@ function handle_exit() {
123
123
elif [ " $LOGOUT_REQUIRED " = " true" ] ; then
124
124
echo " - a logout is required."
125
125
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
127
136
fi
128
137
129
138
# exit as instructed
@@ -229,13 +238,6 @@ echo ""
229
238
# is in the expected location, the necessary symlink can be created by
230
239
# this script and then docker-compose will be installed "correctly".
231
240
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
-
239
241
function is_python_script() {
240
242
[ $( file -b " $1 " | grep -c " ^Python script" ) -gt 0 ] && return 0
241
243
return 1
@@ -305,13 +307,9 @@ else
305
307
echo " having installed docker and docker-compose without using the official"
306
308
echo " 'convenience script'. You may be able to solve this problem by running"
307
309
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"
315
313
echo " (ignore any errors from those commands)"
316
314
else
317
315
echo " \$ sudo apt purge -y docker-compose"
384
382
# implement menu requirements
385
383
if [ -e " $IOTSTACK_MENU_REQUIREMENTS " ] ; then
386
384
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 "
393
387
fi
394
388
395
389
# trigger re-creation of venv on next menu launch. Strictly speaking,
0 commit comments