forked from rivenmedia/riven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
86 lines (71 loc) · 2.33 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/fish
set PUID (set -q PUID; and echo $PUID; or echo 1000)
set PGID (set -q PGID; and echo $PGID; or echo 1000)
echo "Starting Container with $PUID:$PGID permissions..."
if [ "$PUID" = "0" ]
echo running as root user
set USER_HOME "/home/$USERNAME"
mkdir -p $USER_HOME
else
if not echo $PUID | grep -qE '^[0-9]+$'
echo "PUID is not a valid integer. Exiting..."
exit 1
end
if not echo $PGID | grep -qE '^[0-9]+$'
echo "PGID is not a valid integer. Exiting..."
exit 1
end
set -q USERNAME; or set USERNAME riven
set -q GROUPNAME; or set GROUPNAME riven
if not getent group $PGID > /dev/null
addgroup -g $PGID $GROUPNAME
if test $status -ne 0
echo "Failed to create group. Exiting..."
exit 1
end
else
set GROUPNAME (getent group $PGID | cut -d: -f1)
end
if not getent passwd $USERNAME > /dev/null
adduser -D -u $PUID -G $GROUPNAME $USERNAME
if test $status -ne 0
echo "Failed to create user. Exiting..."
exit 1
end
else
if test $PUID -ne 0
usermod -u $PUID -g $PGID $USERNAME
if test $status -ne 0
echo "Failed to modify user UID/GID. Exiting..."
exit 1
end
else
echo "Skipping usermod for root user."
end
end
set USER_HOME "/home/$USERNAME"
mkdir -p $USER_HOME
chown -R $PUID:$PGID $USER_HOME
chown -R $PUID:$PGID /riven/data
end
umask 002
set -x XDG_CONFIG_HOME "$USER_HOME/.config"
set -x XDG_DATA_HOME "$USER_HOME/.local/share"
set -x POETRY_CACHE_DIR "$USER_HOME/.cache/pypoetry"
set -x HOME $USER_HOME
# Ensure poetry is in the PATH
set -x PATH $PATH /app/.venv/bin
su -m $USERNAME -c "poetry config virtualenvs.create false"
set -q ORIGIN; or set ORIGIN "http://localhost:3000"
echo "Container Initialization complete."
# Start rclone in the background
# echo "Starting rclone..."
# rclone rcd --rc-web-gui --rc-addr 0.0.0.0:5572 --rc-no-auth --log-level ERROR &> /dev/null &
# set rclone_pid (jobs -p %1)
# Start the backend
echo "Starting backend..."
su -m $USERNAME -c "fish -c 'cd /riven/backend; and poetry run python3 main.py'" &
set backend_pid (jobs -p %1)
# Start the frontend
echo "Starting frontend..."
exec su -m $USERNAME -c "fish -c 'ORIGIN=$ORIGIN node /riven/frontend/build'"