-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.sh
106 lines (71 loc) · 2.31 KB
/
init.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run the script as root"
exit
fi
## installing python and pip
echo
echo updating packages
apt update
echo
echo installing python and pip
apt install python3 python3-pip -y
## setting up repos environment variables
export DNS_REPOS_ROOT=https://github.com/mafazaa-org
export DNS_INIT=dns-init
export DNS_SERVER=dns-server
export DNS_CHECK=dns-check
export DNS_IP_CONFIRM=dns-ip-confirm
## setup dns-admin user
old_home=/home/ubuntu
username=dns-admin
home=/home/$username
echo ATTENTION
echo username dns-admin will be created right now with the default password dns-admin
echo press enter to continue...
useradd -p $(perl -e 'print crypt($ARGV[0], "password")' 'dns-admin') -m $username -s /bin/bash
echo "user dns-admin added, this script will add dns-admin to the end of sudoers file! do you want to do that manually? (press any key to manually edit/ enter for automatic edit)"
read edit
if [ $edit ]; then
visudo
else
echo "$username ALL=(ALL:ALL) ALL" >> /etc/sudoers
fi
cp $old_home/.ssh $home/.ssh -r
chown -hR $username $home/.ssh
cp $old_home/$DNS_INIT $home/$DNS_INIT -r
chown -hR $username $home/$DNS_INIT
echo the next time, login with $username
read
# adding env to variables
echo export DNS_REPOS_ROOT=$DNS_REPOS_ROOT >> $home/.bashrc
echo export DNS_INIT=$DNS_INIT >> $home/.bashrc
echo export DNS_SERVER=$DNS_SERVER >> $home/.bashrc
echo export DNS_CHECK=$DNS_CHECK >> $home/.bashrc
echo export DNS_IP_CONFIRM=$DNS_IP_CONFIRM >> $home/.bashrc
crontab_file=$username
touch $crontab_file
echo DNS_REPOS_ROOT=$DNS_REPOS_ROOT >> $crontab_file
echo DNS_INIT=$DNS_INIT >> $crontab_file
echo DNS_SERVER=$DNS_SERVER >> $crontab_file
echo DNS_CHECK=$DNS_CHECK >> $crontab_file
echo DNS_IP_CONFIRM=$DNS_IP_CONFIRM >> $crontab_file
cp $crontab_file /var/spool/cron/crontabs/
## freeing port 53
echo
echo uncomment DNS and DNSStubListener and change them to 'primary_server_ip,secondary_server_ip' and no respectively
echo
echo press enter to continue
read
nano /etc/systemd/resolved.conf
echo
echo assuming you did it we are creating a soft link now!
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
echo
echo congratulations, now we are going to shutdown the system
echo
echo "shutdown now? (y/n)"
read shut
if [ $shut == "y" ]; then
shutdown -h now
fi