-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·46 lines (38 loc) · 1.01 KB
/
start.sh
File metadata and controls
executable file
·46 lines (38 loc) · 1.01 KB
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
#!/bin/bash
#setup sshd
mkdir -p /run/sshd
ssh-keygen -A
# update ops
export HOME=/home
export OPS_HOME=/home
ops -update
# setup user workspace
if test -z "$USERID"
then USERID=1000
fi
/usr/sbin/useradd -u "$USERID" -d $HOME -o -U -s /bin/bash devel
# add ssh key
if test -n "$SSHKEY"
then
mkdir -p $HOME/.ssh
touch $HOME/.ssh/authorized_keys
if ! grep "$SSHKEY" $HOME/.ssh/authorized_keys >/dev/null
then echo "$SSHKEY" >>$HOME/.ssh/authorized_keys
fi
chmod 600 $HOME/.ssh/authorized_keys
chmod 700 $HOME/.ssh
fi
touch ~/.bashrc
echo ARCH="$(dpkg --print-architecture)" >>~/.bashrc
echo 'export PATH="$HOME/.local/bin:$HOME:$HOME/.ops/linux-$ARCH/bin:$PATH"' >>~/.bashrc
if [ -n "$OPS_PASSWORD" ] && [ -n "$OPS_USER" ] && [ -n "$OPS_APIHOST" ]
then
cd $HOME
echo -e "OPS_USER=$OPS_USER\nOPS_PASSWORD=$OPS_PASSWORD\nOPS_APIHOST=$OPS_APIHOST\n" >.env
ops ide login
fi
# fix permissions
chmod 0755 $HOME
chown -Rf "$USERID" /home
# start supervisor
supervisord -c /etc/supervisord.ini