-
Notifications
You must be signed in to change notification settings - Fork 9
/
anukotimetrackinstall.sh
312 lines (243 loc) · 11.3 KB
/
anukotimetrackinstall.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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#check if running on ubuntu 20.04
UBU20=$(grep 20.04 "/etc/"*"release")
if ! [[ $UBU20 ]]; then
echo -ne "\033[0;31mThis script will only work on Ubuntu 20.04\e[0m\n"
exit 1
fi
#Enter domain
while [[ $domain != *[.]*[.]* ]]
do
echo -ne "Enter your Domain${NC}: "
read domain
done
#Generate mysql password
mysqlpwd=$(cat /dev/urandom | tr -dc 'A-Za-z0-9%&+?@^~' | fold -w 20 | head -n 1)
echo ${mysqlpwd}
pause
#run update
sudo apt-get update && sudo apt-get -y upgrade
#Install apache2 & mysql
sudo apt-get install -y apache2
sudo apt-get install -y mysql-server
sudo mysql_secure_installation
sudo apt-get install -y php libapache2-mod-php php-mysql php-mbstring php-curl php-gd
sudo apt-get install -y rewrite libapache2-mod-md
sudo apt-get install -y certbot python3-certbot-apache
sudo apt-get install -y unzip
sudo a2enmod md
sudo a2enmod ssl
#Restart apache2
sudo service apache2 restart
#Set firewall
sudo ufw allow OpenSSH
sudo ufw allow 'Apache Full'
sudo ufw enable
#Create and set permissions on webroot
mkdir /var/www/${domain}
chown -R www-data:www-data /var/www/
#Set Apache2 config file
apache2="$(cat << EOF
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName ${domain}
ServerAlias ${domain}
DocumentRoot /var/www/${domain}
ErrorLog /\${APACHE_LOG_DIR}/error.log
CustomLog /\${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOF
)"
echo "${apache2}" > /etc/apache2/sites-available/${domain}.conf
sudo a2ensite ${domain}.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
#run certification
sudo certbot --apache
#Go to webroot
cd /var/www/${domain}
#Download Anuko Time Tracker
wget https://www.anuko.com/download/time_tracker/time_tracker_pdf.zip
unzip time_tracker_pdf.zip
#Move files and fix permissions
mv /var/www/${domain}/timetracker/* /var/www/${domain}/
rm -rf /var/www/${domain}/timetracker/
chown -R www-data:www-data /var/www/
chmod 777 /var/www/${domain}/WEB-INF/templates_c
#Create MySQl DB
mysql -e "CREATE DATABASE timetracker /*\!40100 DEFAULT CHARACTER SET utf8mb4 */;"
mysql -e "CREATE USER timetracker@localhost IDENTIFIED BY '${mysqlpwd}';"
mysql -e "GRANT ALL PRIVILEGES ON timetracker.* TO 'timetracker'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
#TimeTrack config
ttconf="$(cat << EOF
<?php
// +----------------------------------------------------------------------+
// | Anuko Time Tracker
// +----------------------------------------------------------------------+
// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
// +----------------------------------------------------------------------+
// | LIBERAL FREEWARE LICENSE: This source code document may be used
// | by anyone for any purpose, and freely redistributed alone or in
// | combination with other software, provided that the license is obeyed.
// |
// | There are only two ways to violate the license:
// |
// | 1. To redistribute this code in source form, with the copyright
// | notice or license removed or altered. (Distributing in compiled
// | forms without embedded copyright notices is permitted).
// |
// | 2. To redistribute modified versions of this code in *any* form
// | that bears insufficient indications that the modifications are
// | not the work of the original author(s).
// |
// | This license applies to this document only, not any other software
// | that it may be combined with.
// |
// +----------------------------------------------------------------------+
// | Contributors:
// | https://www.anuko.com/time_tracker/credits.htm
// +----------------------------------------------------------------------+
// Set include path for PEAR and its modules, which we include in the distribution.
//
set_include_path(realpath(dirname(__FILE__).'/lib/pear') . PATH_SEPARATOR . get_include_path());
// Database connection parameters.
//
// CHANGE 3 PARAMETERS HERE!
// In this example: "root" is username, "no" is password, "dbname" is database name.
//
define('DSN', 'mysqli://timetracker:${mysqlpwd}@localhost/timetracker?charset=utf8mb4');
// Do NOT change charset unless you upgraded from an older Time Tracker where charset was NOT specified
// and now you see some corrupted characters. See http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html
// MULTIORG_MODE option defines whether users can create their own top groups (organizations).
// When false, a Time Tracker server is managed by admin, who creates top groups (one or many).
//
// Available values are true or false.
//
define('MULTIORG_MODE', false);
// EMAIL_REQUIRED defines whether an email is required for new registrations.
define('EMAIL_REQUIRED', false);
// Directory name.
// If you install time tracker into a sub-directory of your site reflect this in the DIR_NAME parameter.
// For example, for http://localhost/timetracker/ define DIR_NAME as 'timetracker'.
//
// define('DIR_NAME', 'timetracker');
//
define('DIR_NAME', '');
// WEEKEND_START_DAY
//
// This option defines which days are highlighted with weekend color.
// 6 means Saturday. For Saudi Arabia, etc. set it to 4 for Thursday and Friday to be weekend days.
//
define('WEEKEND_START_DAY', 6);
// SESSION_COOKIE_NAME
//
// PHP session cookie name.
// define('SESSION_COOKIE_NAME', 'tt_PHPSESSID');
// PHPSESSID_TTL
//
// Lifetime in seconds for session cookie. Time to live is extended by this value
// with each visit to the site so that users don't have to re-login.
define('PHPSESSID_TTL', 2592000);
//
// Note: see also PHP_SESSION_PATH below as you may have to use it together with
// PHPSESSID_TTL to avoid premature session expirations.
// PHP_SESSION_PATH
// Local file system path for PHP sessions. Use it to isolate session deletions
// (garbage collection interference) by other PHP scripts potentially running on the system.
define('PHP_SESSION_PATH', '/tmp/timetracker'); // Directory must exist and be writable.
// LOGIN_COOKIE_NAME
//
// Cookie name for user login to remember it between browser sessions.
define('LOGIN_COOKIE_NAME', 'tt_login');
// Forum and help links from the main menu.
//
//define('FORUM_LINK', 'https://www.anuko.com/forum/viewforum.php?f=4');
//define('HELP_LINK', 'https://www.anuko.com/time-tracker/user-guide/index.htm');
// Default sender for mail.
//
define('SENDER', 'Anuko Time Tracker <[email protected]>');
// MAIL_MODE - mail sending mode. Can be 'mail' or 'smtp'.
// 'mail' - sending through php mail() function.
// 'smtp' - sending directly through SMTP server.
// See https://www.anuko.com/time_tracker/install_guide/mail.htm
//
define('MAIL_MODE', 'smtp');
define('MAIL_SMTP_HOST', 'localhost'); // For gmail use 'ssl://smtp.gmail.com' instead of 'localhost' and port 465.
// define('MAIL_SMTP_PORT', '465');
// define('MAIL_SMTP_USER', '[email protected]');
// define('MAIL_SMTP_PASSWORD', 'yourpassword');
// define('MAIL_SMTP_AUTH', true);
// define('MAIL_SMTP_DEBUG', true);
// CSS files. They are located in the root of Time Tracker installation.
//
define('DEFAULT_CSS', 'default.css');
define('RTL_CSS', 'rtl.css'); // For right to left languages.
// Default language of the application.
// Possible values: en, fr, nl, etc. Empty string means the language is defined by user browser.
//
define('LANG_DEFAULT', '');
// Default currency symbol. Use €, £, a more specific dollar like US$, CAD, etc.
//
define('CURRENCY_DEFAULT', '£');
// EXPORT_DECIMAL_DURATION - defines whether time duration values are decimal in CSV and XML data exports (1.25 or 1,25 vs 1:15).
//
define('EXPORT_DECIMAL_DURATION', true);
// REPORT_FOOTER - defines whether to use a footer on reports.
//
define('REPORT_FOOTER', true);
// Authentication module (see WEB-INF/lib/auth/)
// Possible authentication methods:
// db - internal database, logins and password hashes are stored in time tracker database.
// ldap - authentication against an LDAP directory such as OpenLDAP or Windows Active Directory.
define('AUTH_MODULE', 'db');
// LDAP authentication examples.
// Go to https://www.anuko.com/time_tracker/install_guide/ldap_auth/index.htm for detailed configuration instructions.
// Configuration example for OpenLDAP server:
// define('AUTH_MODULE', 'ldap');
// $GLOBALS['AUTH_MODULE_PARAMS'] = array(
// 'server' => '127.0.0.1', // OpenLDAP server address or name. For secure LDAP use ldaps://hostname:port here.
// 'type' => 'openldap', // Type of server. openldap type should also work with Sun Directory Server when member_of is empty.
// It may work with other (non Windows AD) LDAP servers. For Windows AD use the 'ad' type.
// 'base_dn' => 'ou=People,dc=example,dc=com', // Path of user's base distinguished name in LDAP catalog.
// 'user_login_attribute' => 'uid', // LDAP attribute used for login.
// 'default_domain' => 'example.com', // Default domain.
// 'member_of' => array()); // List of groups, membership in which is required for user to be authenticated.
// Configuration example for Windows domains with Active Directory:
// define('AUTH_MODULE', 'ldap');
// $GLOBALS['AUTH_MODULE_PARAMS'] = array(
// 'server' => '127.0.0.1', // Domain controller IP address or name. For secure LDAP use ldaps://hostname:port here.
// 'type' => 'ad', // Type of server.
// 'base_dn' => 'DC=example,DC=com', // Base distinguished name in LDAP catalog.
// 'default_domain' => 'example.com', // Default domain.
// 'member_of' => array()); // List of groups, membership in which is required for user to be authenticated.
// Leave it empty if membership is not necessary. Otherwise list CN parts only.
// For example:
// array('Ldap Testers') means that the user must be a member Ldap Testers group.
// array('Ldap Testers', 'Ldap Users') means the user must be a member of both Ldap Testers and Ldap Users groups.
// define('DEBUG', false); // Note: enabling DEBUG breaks redirects as debug output is printed before setting redirect header. Do not enable on production systems.
// Group managers can set monthly work hour quota for years between the following values.
// define('MONTHLY_QUOTA_YEAR_START', 2010); // If nothing is specified, it falls back to 2015.
// define('MONTHLY_QUOTA_YEAR_END', 2025); // If nothing is specified, it falls back to 2030.
// Height in pixels for the note input field in time.php. Defaults to 40.
define('NOTE_INPUT_HEIGHT', 100);
// A comma-separated list of default plugins for new group registrations.
// Example below enables charts and attachments.
// define('DEFAULT_PLUGINS', 'ch,at');
EOF
)"
echo "${ttconf}" > /var/www/${domain}/WEB-INF/config.php
chown -R www-data:www-data /var/www/${domain}/WEB-INF/config.php
printf >&2 "Please setup the database by going to: https://${domain}/dbinstall.php then remove or chmod 000 dbinstall.php"
printf >&2 "\n\n"
printf >&2 "Then login using admin/secret by going to https://${domain}, setup new groups and users and change the admin password from Options menu"
printf >&2 "\n\n"
printf >&2 "Your database user and database name is timetracker and MYSQL password is '${mysqlpwd}'\n\n"
echo "Press any key to finish install"
while [ true ] ; do
read -t 3 -n 1
if [ $? = 0 ] ; then
exit ;
else
echo "waiting for the keypress"
fi
done