-
Notifications
You must be signed in to change notification settings - Fork 1
/
openvpn_change.sh
58 lines (46 loc) · 1.37 KB
/
openvpn_change.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
#!/bin/bash
username=pentest
#hostname=master
#filename=master.ovpn
#Sudo Check
if [ `id -u` -eq 0 ]
then
echo "Running as user with sudo privs :)"
else
echo "Please run with standard (NON ROOT) user and sudo!"
exit 1
fi
#dropbox username
#echo "Please enter dropbox username! (usually pentest)"
#read username
#echo "USERNAME = $username"
echo "Please enter the ovpn file name which will be copied from the /home/$username/ folder!"
read -p 'Filename: ' filename
# if ovpn file does not exist then exit
if [ ! -f /home/$username/$filename ]
then
echo "$filename not found. Exiting!"
exit 1
else
echo "File found. Copying now..."
fi
sudo cp /home/$username/$filename /etc/openvpn/openvpn.conf
#sudo rm /home/$username/$filename
sudo systemctl enable openvpn
echo "Copied and enabled dropbox openvpn file!"
echo #### Setting Hostname ####
echo "Enter New Host Name [dropbox name OR company name]"
read -p 'Hostname: ' hostname
sudo hostnamectl set-hostname $hostname
sed -I "s/127.0.1.1.*/127.0.1.1\t$hostname/g" /etc/hosts
echo "Hostname set to $hostname"
### Reboot Prompt
read -p "New openvpn cert ($filename) is installed. Do you want to reboot? y/n: " prompt
if [[ "$prompt" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "REBOOTING IN 5 SECONDS......."
sleep 5
sudo reboot
else
echo "Reboot Skipped. It is recommended to reboot!!!!!!"
fi