diff options
-rwxr-xr-x | check-for-short_url.sh | 4 | ||||
-rwxr-xr-x | config/hex-zero.init | 2 | ||||
-rw-r--r-- | debian/install | 2 | ||||
-rwxr-xr-x | debian/install-short_url-for-hex-zero.sh | 8 | ||||
-rw-r--r-- | debian/postinst | 7 |
5 files changed, 15 insertions, 8 deletions
diff --git a/check-for-short_url.sh b/check-for-short_url.sh index 7d37d37..2160d52 100755 --- a/check-for-short_url.sh +++ b/check-for-short_url.sh @@ -9,9 +9,9 @@ echo "import short_url" | $( which python3 2>/dev/null ) 2>/dev/null && exit 0 # # so we need to check the configured user, if we are not that user already. test "${UWSGI_USER}" != "${USER}" && { echo "Will attempt to switch user to ${UWSGI_USER} and check for short_url." 1>&2 - echo "import short_url" | sudo su "${UWSGI_USER}" -c "$( which python3 2>/dev/null ) 2>/dev/null" && exit 0 # short-circuit if we find it + echo "import short_url" | sudo su "${UWSGI_USER}" -s /bin/sh -c "$( which python3 2>/dev/null ) 2>/dev/null" && exit 0 # short-circuit if we find it } echo "Please run something similar to the following, before running hex-zero:" -echo "sudo su ${UWSGI_USER} -c 'pip3 --user install short_url'" +echo "sudo su ${UWSGI_USER} -s /bin/sh -c 'pip3 install --user short_url'" exit 1 diff --git a/config/hex-zero.init b/config/hex-zero.init index 6717ada..c991652 100755 --- a/config/hex-zero.init +++ b/config/hex-zero.init @@ -55,7 +55,7 @@ do_start() # The above code will not work for interpreted scripts, use the next # six lines below instead (Ref: #643337, start-stop-daemon(8) ) test -r /var/www/hex-zero/check-for-short_url.sh && { - /bin/sh /var/www/hex-zero/check-for-short_url.sh || { + /bin/sh /var/www/hex-zero/check-for-short_url.sh 1>/dev/null 2>&1 || { # the init script is somehow prevent all displayed output even when directly outputing it to /dev/pts/3 echo "Please run something similar to the following, before running hex-zero:" echo "sudo su ${USER} -c 'pip3 --user install short_url'" diff --git a/debian/install b/debian/install index 4a97dfa..8bd6e93 100644 --- a/debian/install +++ b/debian/install @@ -1 +1 @@ -# You must remove unused comment lines for the released package. +debian/install-short_url-for-hex-zero.sh /usr/libexec/hex-zero diff --git a/debian/install-short_url-for-hex-zero.sh b/debian/install-short_url-for-hex-zero.sh new file mode 100755 index 0000000..780324b --- /dev/null +++ b/debian/install-short_url-for-hex-zero.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# Must be run as root. +USERNAME=hex-zero +# install short_url for the user only +if ! /var/www/hex-zero/check-for-short_url.sh 1>/dev/null 2>&1 ; +then + su ${USERNAME} -s /bin/sh -c 'pip3 install --user short_url' +fi diff --git a/debian/postinst b/debian/postinst index 0e4f748..a1e461a 100644 --- a/debian/postinst +++ b/debian/postinst @@ -17,7 +17,7 @@ case "$1" in adduser --quiet --system --home $HOME \ --disabled-password --group \ --gecos "0x0 system user" \ - ${USERNAME} > ${OUT} + ${USERNAME} > ${OUT} 2>&1 fi chown ${USERNAME}:${USERNAME} \ ${HOME} ${HOME}/* \ @@ -25,11 +25,10 @@ case "$1" in if ! test -r /var/www/hex-zero/db.sqlite || test $( stat -c "%s" /var/www/hex-zero/db.sqlite 2>/dev/null ) -lt 50 ; then # detect if short_url exists for the user - result="$( su ${USERNAME} -c 'echo "import short_url" | python3 1>/dev/null 2>&1 && echo good || echo bad' )" + result="$( sh /var/www/hex-zero/check-for-short_url.sh 1>/dev/null 2>&1 && echo good || echo bad )" if test "${result}" = "bad" ; then - echo "Please install python3 module short_url for user ${USERNAME}, and re-run \`sudo dpkg-reconfigure hex-zero\` Using the following command would work." - echo " sudo su ${USERNAME} -c 'pip3 install --user short_url'" + echo "Please install python3 module short_url with \`/usr/libexec/hex-zero/install-short_url-for-hex-zero.sh\` and then dpkg-reconfigure hex-zero." else echo "Initializing sqlite database for hex-zero" su ${USERNAME} -c 'cd /var/www/hex-zero ; /var/www/hex-zero/hex_zero.py db init' 2>/dev/null || : |