diff options
author | B Stack <bgstack15@gmail.com> | 2020-12-09 21:35:05 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-12-09 21:35:05 -0500 |
commit | fae813e25cb89b8b8f329e56c317b30c4f3edecd (patch) | |
tree | 6d6f610e3f4deb11746a809c4f336108f1eb59e0 /check-for-short_url.sh | |
parent | fix init script and pidfile ownership (diff) | |
download | hex-zero-fae813e25cb89b8b8f329e56c317b30c4f3edecd.tar.gz hex-zero-fae813e25cb89b8b8f329e56c317b30c4f3edecd.tar.bz2 hex-zero-fae813e25cb89b8b8f329e56c317b30c4f3edecd.zip |
add check-for-short_url and fix init user check
Diffstat (limited to 'check-for-short_url.sh')
-rwxr-xr-x | check-for-short_url.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/check-for-short_url.sh b/check-for-short_url.sh new file mode 100755 index 0000000..7d37d37 --- /dev/null +++ b/check-for-short_url.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# This script exists because Debian does not package short_url in a dpkg +test -r /etc/default/hex-zero && . /etc/default/hex-zero + +# check global python for short_url +echo "import short_url" | $( which python3 2>/dev/null ) 2>/dev/null && exit 0 # short-circuit if we find it + +# So if we get here, it was not installed globally, +# 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 "Please run something similar to the following, before running hex-zero:" +echo "sudo su ${UWSGI_USER} -c 'pip3 --user install short_url'" +exit 1 |