aboutsummaryrefslogtreecommitdiff
path: root/check-for-short_url.sh
blob: 7d37d37dfb7c0f50021cb983a85cae1c3af2bbe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
bgstack15