forked from john-shine/mega.syno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·65 lines (57 loc) · 1.97 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
#!/bin/bash
rm -f /tmp/.X*-lock /tmp/.X11-unix/X*; [[ -z "${DISPLAY}" ]] || /usr/bin/vncserver -kill ${DISPLAY} && sleep 3
if [[ -d ${HOME}/MEGA ]]; then
uid=$(stat -c '%u' ${HOME}/MEGA)
gid=$(stat -c '%g' ${HOME}/MEGA)
if getent passwd $uid > /dev/null 2>&1; then
echo "user exists"
gid_=$(id -g $uid)
if [[ $gid -ne $gid_ ]]; then
if getent group $gid > /dev/null 2>&1; then
echo "group exists."
else
echo "group not exists."
groupadd -g $gid -r "${USER}"
fi
usermod -d ${HOME} -g $gid -aG $gid -s /bin/bash -p {$USER} `id -un $uid`
fi
else
echo "user not exist"
if getent group $gid > /dev/null 2>&1; then
echo "group exists."
else
echo "group not exists."
groupadd -g $gid -r "${USER}"
fi
useradd -u $uid -d ${HOME} -g $gid -s /bin/bash -p ${USER} -r -N ${USER}
fi
fi
if [[ $uid -ne 0 ]]; then
chown -R $uid:$gid ${HOME}
if [[ ! -z $vnc_password ]]; then
su - -p -c "echo \"${vnc_password}\" | vncpasswd -f > ${HOME}/.vnc/passwd" `id -un $uid`
fi
if [[ -z $vnc_password ]]; then
su - -p -c "/usr/bin/vncserver -geometry 1024x768 -fg -SecurityTypes None,TLSNone" `id -un $uid`
else
su - -p -c "/usr/bin/vncserver -geometry 1024x768 -fg" `id -un $uid`
fi
else
if [[ ! -f "/root/.Xauthority" ]]; then
cp ${HOME}/.Xauthority /root/.Xauthority
fi
if [[ ! -d "/root/.vnc" ]]; then
cp -r ${HOME}/.vnc /root/.vnc
fi
if [[ ! -d "/root/.fluxbox" ]]; then
cp -r ${HOME}/.fluxbox /root/.fluxbox
fi
if [[ ! -z $vnc_password ]]; then
echo "${vnc_password}" | vncpasswd -f > ${HOME}/.vnc/passwd
fi
if [[ -z $vnc_password ]]; then
/usr/bin/vncserver -geometry 1024x768 -fg -SecurityTypes None,TLSNone
else
/usr/bin/vncserver -geometry 1024x768 -fg
fi
fi