-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathset_root_pw.sh
executable file
·42 lines (34 loc) · 1.4 KB
/
set_root_pw.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
#!/bin/bash
if [ -f /data/persistant/.root_pw_set ]; then
echo "Root password already set!"
exit 0
fi
PASS=${ROOT_PASS:-$(pwgen -s 12 1)}
_word=$( [ ${ROOT_PASS} ] && echo "preset" || echo "random" )
echo "=> Setting a ${_word} password to the root user"
echo "root:$PASS" | chpasswd
echo "=> Done!"
touch /data/persistent/.root_pw_set
UPCASED_UPCASED_SSH_SERVER=`echo "$SSH_SERVER" | tr '[a-z]' '[A-Z]'`
if [ "$UPCASED_SSH_SERVER" == "FALSE" ] || [ "$UPCASED_SSH_SERVER" == "0" ]; then
echo "========================================================================"
echo You can now connect to this Ubuntu container
echo ""
echo To acces docker TTY locally
echo " docker exec -it [container-id] bash"
echo ""
echo The root password is : '$PASS'
echo ""
echo "Please remember to change the above password as soon as possible!"
else
echo "========================================================================"
echo "You can now connect to this Ubuntu container"
echo ""
echo " Using SSH, for reach 1st interface ip at port 22"
echo " ssh root@"$(ip -o -4 addr show | awk -F '[ /]+' '/global/ {print $4}' | head -n1)
echo ""
echo "and enter the root password '$PASS' when prompted"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "========================================================================"
fi