-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathentrypoint.sh
60 lines (49 loc) · 1.85 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
echo ~~~ ydl_api_ng
echo ~~~ Revision : $GIT_BRANCH - $GIT_REVISION
echo ~~~ Docker image generated : $DATE
mkdir -p /app/logs /app/downloads /app/params /app/tmp /app/data /root/yt-dlp-plugins /app/cookies/ /home/ydl_api_ng
getent group $GID >/dev/null
if [ ! $? -eq 0 ]; then
addgroup --gid $GID ydl_api_ng
fi
getent passwd $UID >/dev/null
if [ ! $? -eq 0 ]; then
useradd --uid $UID --gid $GID ydl_api_ng -b /home/ydl_api_ng
fi
# If params.ini exists, assume setup has been run. Don't copy extra files the user may have removed.
if [ ! -e '/app/params/params.ini' ]; then
cp -n /app/setup/params.ini /app/params/
fi
if [ ! -e /app/data/database.json ]; then
touch /app/data/database.json
fi
if [ "$FORCE_YTDLP_VERSION" == "" ]; then
echo --- Upgrade yt-dlp to the latest version ---
pip3 install yt-dlp --upgrade --disable-pip-version-check -q --root-user-action=ignore
else
echo --- Force yt-dlp version $FORCE_YTDLP_VERSION ---
pip3 install --disable-pip-version-check -q --root-user-action=ignore yt-dlp==$FORCE_YTDLP_VERSION --force-reinstall
fi
echo --- Installing hooks requirements ---
if [ -e /app/params/hooks_requirements ]; then
pip3 install --disable-pip-version-check -q --root-user-action=ignore -r /app/params/hooks_requirements
else
pip3 install --disable-pip-version-check -q --root-user-action=ignore -r /app/setup/hooks_requirements
fi
chown -R $UID:$GID /app
chown $UID:$GID /home/ydl_api_ng /root/yt-dlp-plugins
chmod a+x /root/ entrypoint.sh
if [ "$DISABLE_REDIS" == "false" ]; then
if [ -e /app/params/workers.ini ]; then
supervisord -c /app/params/workers.ini
else
supervisord -c /app/setup/workers.ini
fi
fi
if [ "$DEBUG" == "DEBUG" ]; then
echo ~~~ Launching DEBUG mode ~~~
su "$(id -un $UID)" -c "uvicorn main:app --reload --port 80 --host 0.0.0.0"
else
su "$(id -un $UID)" -c "python3 main.py"
fi