-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathINSTALL
executable file
·79 lines (52 loc) · 1.7 KB
/
INSTALL
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
#!/bin/bash
# if you want to call the program something different change the Alias variable below
ALIAS='extshark'
# there should be no need but if you want to change where things are stored do so here
WEBROOT='/usr/share/'$ALIAS'/htdocs'
APACHECONF='/etc/apache2/conf-available/'$ALIAS'.conf'
ETC='/etc/'$ALIAS
#make sure that the script is being run as root
if [ $LOGNAME != "root" ]; then
echo "Please run this script as root!"
exit 1
fi
# create directory if not already created
if [ ! -f $WEBROOT ]; then
mkdir -p $WEBROOT
fi
if [ ! -f $ETC ]; then
mkdir -p $ETC
fi
# copy files to proper directory (take out the v if you dont want verbose)
cp -rvf ./* $WEBROOT
chgrp www-data $WEBROOT/data
chmod g+w $WEBROOT/data
#TODO write script to run through directorys and check for proper permissions
#
# if a different alias is used change the page title as well as anything thing else called ExtShark
if [ "$ALIAS" != "extshark" ]; then
sed -i "s/ExtShark/$ALIAS/g" $WEBROOT/index.*
fi
# add configuration file to apache conf-available
printf "Alias /$ALIAS $WEBROOT
<DirectoryMatch ($WEBROOT)>
Options FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride AuthConfig
Order Allow,Deny
Allow From All
AuthName \"extshark Access\"
AuthType Basic
AuthUserFile $ETC/htpasswd.users
require valid-user
</DirectoryMatch>
<Directory $WEBROOT>
Options +ExecCGI
</Directory>" > $APACHECONF
#create default user with very vary bad password
htpasswd -b -c $ETC/htpasswd.users admin password
#navigate to apache confs directory and enable site
cd /etc/apache2/conf-available
a2enconf $ALIAS
#get out of here
exit 0