This repository has been archived by the owner on Oct 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathrun
executable file
·70 lines (63 loc) · 1.62 KB
/
run
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
#!/bin/bash
# Create dbus unique id
apk add dbus
dbus-uuidgen --ensure
# Create group
egrep -i "^${GNAME}" /etc/group;
if [ $? -ne 0 ]; then
echo "${GNAME}:x:${GID}:${UNAME}" >> /etc/group
fi
# Create user
if ! id "${UNAME}" >/dev/null 2>&1; then
echo "${UNAME}:x:${UID}:${GID}:${UNAME},,,:${UHOME}:${SHELL}" >> /etc/passwd
echo "${UNAME}::17032:0:99999:7:::" >> /etc/shadow
fi
# Create HOME dir
if [ -d "${UHOME}" ]
then
home_owner="$(stat -c '%U' ${UHOME})"
if [ $(id -u ${UNAME}) -ne $(id -u ${home_owner}) ]; then
chown "${UID}":"${GID}" -R ${UHOME}
fi
else
mkdir -p "${UHOME}"
chown "${UID}":"${GID}" "${UHOME}"
fi
# SSH
sed -i "s/^Port .*$/Port ${SSHD_PORT}/" "/etc/ssh/sshd_config"
mkdir -p "${UHOME}/.ssh"
find /etc/pub-keys -type f -name *.pub -exec cat "{}" >> "${UHOME}/.ssh/authorized_keys" \;
chmod 600 -R "${UHOME}/.ssh"
chmod 700 "${UHOME}/.ssh"
export XDG_RUNTIME_DIR=/tmp/xdg
mkdir -p "${XDG_RUNTIME_DIR}" "/run/user/${UID}/"
chown "${UID}":"${GID}" "${XDG_RUNTIME_DIR}" "/run/user/${UID}/"
if [ "$START_XORG" == "yes" ]; then
chmod 1777 /tmp/.X11-unix
/usr/libexec/Xorg\
-noreset\
-novtswitch\
-nolisten tcp\
+extension GLX\
+extension RANDR\
+extension RENDER\
-config /etc/xpra/xorg.conf\
-dpi $XORG_DPI\
-logfile /tmp/Xorg.log\
-xinerama &
fi
case "$MODE" in
'tcp')
echo "Starting in the tcp mode."
su-exec "${UNAME}" bash tcp_m "$@"
;;
'ssh')
echo "Starting in the ssh mode..."
/usr/sbin/sshd
su-exec "${UNAME}" bash ssh_m "$@"
;;
*)
echo "MODE variable specifies unknown run-mode!\nExiting..."
exit 1
;;
esac