forked from hoelsner/network-config-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_ubuntu.sh
executable file
·92 lines (83 loc) · 3.33 KB
/
setup_ubuntu.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
#!/usr/bin/env bash
echo "-------------------------------------------------------------------------------------------------"
echo " Network Configuration Generator - Ubuntu 14.04"
echo "-------------------------------------------------------------------------------------------------"
echo ""
echo "This script stages the \"Network Configuration Generator\" Web service on the host. It installs"
echo "all dependencies, including nginx and gunicorn."
echo ""
echo "The script will create a new user \"ncg\", that is used to run the service."
echo ""
echo "PLEASE NOTE: This script assumes, that this Web service is the only application running on "
echo "the host."
echo ""
echo "-------------------------------------------------------------------------------------------------"
echo "Do you wish to continue?"
select result in Yes No
do
case ${result} in
"Yes" )
extra_vars=""
echo "Do you want to use systemd? (only with Ubuntu > 14.04)"
select sub_result in Yes No
do
case ${sub_result} in
"Yes" )
extra_vars+=" use_systemd=true"
break
;;
*)
break
;;
esac
done
echo "---------------------------------"
echo "Do you want to configure the local services (FTP/TFTP)?"
echo "---------------------------------"
select sub_result in Yes No
do
case ${sub_result} in
"Yes" )
extra_vars+=" configure_local_services=true"
break
;;
*)
break
;;
esac
done
echo "---------------------------------"
echo "Install Ansible..."
echo "---------------------------------"
sudo apt-add-repository ppa:ansible/ansible -y
sudo apt-get update
sudo apt-get install ansible -y
echo "---------------------------------"
echo "create Network Configuration Generator user..."
echo "---------------------------------"
sudo adduser ncg --home /home/ncg --disabled-password
sudo adduser ncg sudo
echo "---------------------------------"
echo "copy source files to /var/www/network_config_generator"
echo "---------------------------------"
source_dir="/var/www/network_config_generator"
sudo mkdir -p ${source_dir}
sudo chown ncg ${source_dir}
sudo chgrp ncg ${source_dir}
sudo -u ncg cp -r * ${source_dir}
echo "---------------------------------"
echo "Setup of the Network Configuration Generator Web service..."
echo "---------------------------------"
cd ${source_dir}
ansible-playbook -i 'localhost,' -c local deploy/setup.yaml --ask-sudo-pass --extra-vars "${extra_vars}"
echo "---------------------------------"
echo "Setup complete."
echo ""
break
;;
* )
echo "Okay, exit setup."
break
;;
esac
done