-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
119 lines (97 loc) · 3.53 KB
/
install.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
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
_check_rdp_profiles() {
echo "Searching for rdp profiles..."
if [ "$(find "./ntos/rdp" -maxdepth 1 -type f -name "*.rdp" | wc -l)" -gt 0 ]; then
echo "Found one or more .rdp files in ./ntos/rdp"
ls "./ntos/rdp"/*.rdp
else
echo "No .rdp files found in ./ntos/rdp"
fi
}
_check_installed_webserver() {
echo "Searching for pre-installed apache2 or nginx webserver application..."
apache_installed=$(dpkg --get-selections | grep apache2 | cut -f1)
nginx_installed=$(dpkg --get-selections | grep nginx | cut -f1)
if [ -z "$apache_installed" ]; then
preflight_check=0
else
echo 'Apache2 looks to in an installed state'
printf 'What is the directory to place HTML files? (Default: /var/www/html/) '
read -r custom_path
preflight_check=1
if [ -z "$custom_path" ]; then
web_file_path='/var/www/html/'
else
web_file_path="$custom_path"
fi
return
fi
if [ -z "$nginx_installed" ]; then
preflight_check=0
else
echo 'NGINX looks to in an installed state'
printf 'What is the directory to place HTML files? (Default: /usr/share/nginx/html/) '
read -r custom_path
preflight_check=1
if [ -z "$custom_path" ]; then
web_file_path='/usr/share/nginx/html/'
else
web_file_path="$custom_path"
fi
return
fi
if [ "$preflight_check" -eq 0 ]; then
printf 'No Apache2 or NGINX installation found. Do you want this script to install it? (It will install Apache2) (y/N) '
read -r user_granted_install_permission
if [[ "$user_granted_install_permission" =~ ^[yY]$ ]]; then
install_apache2_webserver
return
fi
printf 'Do you want to specify a custom HTML directory? (y/N) '
read -r user_wants_custom
if [[ "$user_wants_custom" =~ ^[yY]$ ]]; then
printf 'What should the custom location be? Enter: '
read -r web_file_path
preflight_check=1
else
echo 'Please install either Apache2 or NGINX first, and then rerun this.'
exit 0
fi
fi
}
_check_user_perms() {
if [ "$(id -u)" -eq 0 ]; then
return
else
echo 'Insufficient privileges.'
exit 1
fi
}
install_apache2_webserver() {
_check_user_perms
echo 'Installing apache2...'
apt install -y apache2 &> /dev/null
_check_installed_webserver
}
copy_ntos_files() {
if [ -w "$web_file_path" ]; then
echo "Copying files to their respective places..."
cp -rv ./ntos/* "$web_file_path"
else
_check_user_perms
fi
echo "Done copying."
}
main() {
_check_rdp_profiles
_check_installed_webserver
echo "Chosen HTML-filepath is: ${web_file_path}"
if [ "$preflight_check" -eq 1 ]; then
copy_ntos_files
else
echo "Something is missing"
exit 1
fi
echo "Succesfully installed."
}
main