Skip to content

Commit 91c850a

Browse files
authored
Removed 'root' docker initialization requirement (#238)
1 parent 9592b9b commit 91c850a

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

apprise_api/supervisord-startup

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,51 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
if [ $(id -u) -ne 0 ]; then
26-
echo "You must be root to run this script."
27-
echo "Caution: This should only be ran in a dockerized instance!"
28-
exit 1
29-
fi
25+
if [ $(id -u) -eq 0 ]; then
26+
#
27+
# Root User
28+
#
29+
echo "Apprise API Super User Startup"
3030

31-
# Default values
32-
PUID=${PUID:=1000}
33-
PGID=${PGID:=1000}
31+
# Default values
32+
PUID=${PUID:=1000}
33+
PGID=${PGID:=1000}
3434

35-
# lookup our identifier
36-
GROUP=$(getent group $PGID 2>/dev/null | cut -d: -f1)
37-
[ -z "$GROUP" ] && groupadd --force -g $PGID apprise &>/dev/null && \
38-
GROUP=apprise
35+
# lookup our identifier
36+
GROUP=$(getent group $PGID 2>/dev/null | cut -d: -f1)
37+
[ -z "$GROUP" ] && groupadd --force -g $PGID apprise &>/dev/null && \
38+
GROUP=apprise
3939

40-
USER=$(id -un $PUID 2>/dev/null)
41-
[ $? -ne 0 ] && useradd -M -N \
42-
-o -u $PUID -G $GROUP -c "Apprise API User" -d /opt/apprise apprise && \
43-
USER=apprise
40+
USER=$(id -un $PUID 2>/dev/null)
41+
[ $? -ne 0 ] && useradd -M -N \
42+
-o -u $PUID -G $GROUP -c "Apprise API User" -d /opt/apprise apprise && \
43+
USER=apprise
4444

45-
if [ -z "$USER" ]; then
46-
echo "The specified User ID (PUID) of $PUID is invalid; Aborting operation."
47-
exit 1
45+
if [ -z "$USER" ]; then
46+
echo "The specified User ID (PUID) of $PUID is invalid; Aborting operation."
47+
exit 1
4848

49-
elif [ -z "$GROUP" ]; then
50-
echo "The specified Group ID (PGID) of $PGID is invalid; Aborting operation."
51-
exit 1
52-
fi
49+
elif [ -z "$GROUP" ]; then
50+
echo "The specified Group ID (PGID) of $PGID is invalid; Aborting operation."
51+
exit 1
52+
fi
5353

54-
# Ensure our group has been correctly assigned
55-
usermod -a -G $GROUP $USER &>/dev/null
56-
chmod o+w /dev/stdout /dev/stderr
54+
# Ensure our group has been correctly assigned
55+
usermod -a -G $GROUP $USER &>/dev/null
56+
chmod o+w /dev/stdout /dev/stderr
57+
58+
else
59+
#
60+
# Non-Root User
61+
#
62+
echo "Apprise API Non-Super User Startup"
63+
USER=$(id -un 2>/dev/null)
64+
GROUP=$(id -gn 2>/dev/null)
65+
fi
5766

5867
[ ! -d /attach ] && mkdir -p /attach
5968
chown -R $USER:$GROUP /attach
60-
[ ! -d /config ] && mkdir -p /config /config/store
69+
[ ! -d /config/store ] && mkdir -p /config/store
6170
chown $USER:$GROUP /config
6271
chown -R $USER:$GROUP /config/store
6372
[ ! -d /plugin ] && mkdir -p /plugin
@@ -91,5 +100,6 @@ cd /opt/apprise
91100

92101
# Launch our SupervisorD
93102
/usr/local/bin/supervisord -c /opt/apprise/webapp/etc/supervisord.conf
103+
94104
# Always return our SupervisorD return code
95105
exit $?

0 commit comments

Comments
 (0)