forked from n9986/beacon
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigure
executable file
·195 lines (159 loc) · 6.71 KB
/
configure
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
TMP=/tmp/tmpfile
echo ""
echo "Beacon configuration script"
# echo "This configuration script should only be run once. If you want to change settings again, you'll have to unzip the archive and start over."
echo ""
echo ""
cp httpd-beacon.conf.sample httpd-beacon.conf
cd beacon
sed -e '/^\/\//d' -e '/ \/\//d' -e '/^$/d' beacon.conf.sample > beacon.conf
# next step is to update beacon.conf from user input
# see http://stackoverflow.com/questions/15272244/how-to-replace-value-of-key-in-json-file-using-sed
# fields to fill from user input: text (default)
# domain for URL (localhost)
read -p "Domain for URL: " -e -i "localhost" domain
echo $domain
sed 's/"url": "http:\/\/localhost\//"url": "http:\/\/'${domain}'\//' beacon.conf > $TMP
cat $TMP > beacon.conf
# backend (php)
read -p "Backend: " -e -i "php" backend
echo $backend
sed 's/"backend": "php"/"backend": "'${backend}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# path for URL (beacon)
read -p "Path for URL (example: http://${domain}/beacon/: " -e -i "beacon" urlpath
echo $urlpath
# update paths
sed 's/path": "beacon\//path": "'${urlpath}'\//' beacon.conf > $TMP
cat $TMP > beacon.conf
sed 's/"url": "http:\/\/'${domain}'\/beacon\//"url": "http:\/\/'${domain}'\/'${urlpath}'\//' beacon.conf > $TMP
cat $TMP > beacon.conf
# update apache conf file
sed 's/Alias \/beacon \/usr\/share\/beacon/Alias \/'${urlpath}' \/usr\/share\/beacon/' ../httpd-beacon.conf > $TMP
cat $TMP > ../httpd-beacon.conf
# dbtype (mysql)
read -p "Database type: " -e -i "mysql" dbtype
echo $dbtype
sed 's/"dbtype": "mysql"/"dbtype": "'${dbtype}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# db hostname (localhost)
read -p "Database hostname: " -e -i "localhost" dbhostname
echo $dbhostname
sed 's/"hostname": "localhost"/"hostname": "'${dbhostname}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# db database (beacon)
read -p "Database name: " -e -i "beacon" dbdatabase
echo $dbdatabase
sed 's/"database": "beacon"/"database": "'${dbdatabase}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# db username (beacon)
read -p "Database username: " -e -i "beacon" dbusername
echo $dbusername
sed 's/"username": "beacon"/"username": "'${dbusername}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# db password (beacon)
read -p "Database password: " -e -i "beacon" dbpassword
echo $dbpassword
sed 's/"password": "beacon"/"password": "'${dbpassword}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# auth type (db)
read -p "Authentication type (db,ldap): " -e -i "db" authtype
echo $authtype
sed 's/"authtype": "db"/"authtype": "'${authtype}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# only gather ldap info if ldap is being used for auth
if [ "${authtype}" = "ldap" ]
then
# ldap account_suffix (@example.com)
read -p "LDAP Account Suffix: " -e -i "@example.com" ldap_account_suffix
echo $ldap_account_suffix
sed 's/"account_suffix": "@example.com"/"account_suffix": "'${ldap_account_suffix}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap base_dn (DC=example,DC=com)
read -p "LDAP Base DN: " -e -i "DC=example,DC=com" ldap_base_dn
echo $ldap_base_dn
sed 's/"base_dn": "DC=example,DC=com"/"base_dn": "'${ldap_base_dn}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap required_group ()
read -p "LDAP Required Group: " -e -i "" ldap_required_group
echo $ldap_required_group
sed 's/"required_group": ""/"required_group": "'${ldap_required_group}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap domain_controller1 (dc1.example.com)
read -p "LDAP Domain Controller 1: " -e -i "dc1.example.com" ldap_domain_controller1
echo $ldap_domain_controller1
sed 's/"dc1.example.com"/"'${ldap_domain_controller1}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap domain_controller2 (dc2.example.com)
read -p "LDAP Domain Controller 2: " -e -i "dc2.example.com" ldap_domain_controller2
echo $ldap_domain_controller2
sed 's/"dc2.example.com"/"'${ldap_domain_controller2}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap admin_username (ldapusername)
read -p "LDAP Admin Username: " -e -i "ldapusername" ldap_admin_username
echo $ldap_admin_username
sed 's/"admin_username": "ldapusername"/"admin_username": "'${ldap_admin_username}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap admin_password (ldappassword)
read -p "LDAP Admin Password: " -e -i "ldappassword" ldap_admin_password
echo $ldap_admin_password
sed 's/"admin_password": "ldappassword"/"admin_password": "'${ldap_admin_password}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap real_primarygroup (false)
read -p "LDAP Real Primary Group: " -e -i "false" ldap_real_primarygroup
echo $ldap_real_primarygroup
sed 's/"real_primarygroup": false/"real_primarygroup": '${ldap_real_primarygroup}'/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap use_ssl ()
read -p "LDAP Use SSL: " -e -i "" ldap_use_ssl
echo $ldap_use_ssl
sed 's/"use_ssl": ""/"use_ssl": "'${ldap_use_ssl}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap use_tls ()
read -p "LDAP Use TLS: " -e -i "" ldap_use_tls
echo $ldap_use_tls
sed 's/"use_tls": ""/"use_tls": "'${ldap_use_tls}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap recursive_groups ()
read -p "LDAP Recursive Groups: " -e -i "" ldap_recursive_groups
echo $ldap_recursive_groups
sed 's/"recursive_groups": ""/"recursive_groups": "'${ldap_recursive_groups}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap ad_port (389)
read -p "LDAP AD Port Number: " -e -i "389" ldap_ad_port
echo $ldap_ad_port
sed 's/"ad_port": "389"/"ad_port": "'${ldap_ad_port}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# ldap sso ()
read -p "LDAP SSO: " -e -i "" ldap_sso
echo $ldap_sso
sed 's/"sso": ""/"sso": "'${ldap_sso}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
fi
# language (en_US)
read -p "Language: " -e -i "en_US" language
echo $language
sed 's/"language": "en_US"/"language": "'${language}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# container (#container)
read -p "HTML container element: " -e -i "#container" container
echo $container
sed 's/"container": "#container"/"container": "'${container}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# isRoot (true)
read -p "isRoot: " -e -i "true" isroot
echo $isroot
sed 's/"isRoot": true/"isRoot": '${isroot}'/' beacon.conf > $TMP
cat $TMP > beacon.conf
# theme (redmond)
read -p "jQuery UI Theme: " -e -i "redmond" theme
echo $theme
sed 's/"theme": "redmond"/"theme": "'${theme}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
# storage (flatfile)
read -p "Storage: " -e -i "flatfile" storage
echo $storage
sed 's/"storage": "flatfile"/"storage": "'${storage}'"/' beacon.conf > $TMP
cat $TMP > beacon.conf
echo "To add custom commands, manually edit the beacon.conf file before running make install"