This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup
executable file
·77 lines (66 loc) · 3.08 KB
/
setup
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
#!/usr/bin/env bash
printf "\n* * * * * \n\nStarting setup. Your sudo password will be required.\n\n* * * * *\n\n"
# REQUIRED
printf "\nPreparing directory for install...\n"
sudo chmod -R 777 .
# OPTIONAL (but convenient)
git config core.fileMode false
printf "\nConfiguring Git to ignore file mode changes\n"
# REQUIRED
printf "\nInstalling global Composer dependencies...\n"
composer global require "fxp/composer-asset-plugin:^1.1"
printf "\nInstalling this package's Composer dependencies...\n"
composer install -o --prefer-dist
# REQUIRED
if [ ! -f config.xml ]; then
printf "\nPreparing configuration file `config.xml`...\n"
cp config.example.xml config.xml
fi
# OPTIONAL (but a good idea)
APACHE_USER=${1:-"www-data"}
APACHE_GROUP=${2:-$APACHE_USER}
printf "\nTransfering ownership to $APACHE_USER:$APACHE_GROUP as the Apache user:group.\n"
sudo chown -R $APACHE_USER:$APACHE_GROUP .
# OPTIONAL (but a good idea)
printf "\nSetting secure file permissions...\n"
sudo find . -type d -exec chmod 550 {} +
sudo find . -type f -exec chmod 440 {} +
sudo chmod 750 setup
sudo chmod 750 cron/data-collection.php
sudo find .git -type d -exec chmod 750 {} +
sudo find .git -type f -exec chmod 640 {} +
# REQUIRED (may require MORE if ownershop was not transferred to Apache)
printf "Setting file permissions to allow Smarty caching...\n"
sudo chmod 750 vendor/battis/bootstrapsmarty/templates_c
sudo find vendor/battis/bootstrapsmarty/templates_c/*.php -type f -exec chmod 640 {} +
sudo chmod 750 vendor/battis/bootstrapsmarty/cache
sudo find vendor/battis/bootstrapsmarty/cache/*.php -type f -exec chmod 640 {} +
printf "Setting file permissions to allow logging...\n"
sudo chmod 750 logs
sudo find logs/*.log -type f -exec chmod 640 {} +
# Honor SELinux, if present
if type sestatus &>/dev/null ; then
SELINUX_ENABLED=$(sestatus | grep -oP "(?<=^Current mode:).*")
if [ $SELINUX_ENABLED == "enabled" ]; then
printf "Updating SELinux context for Smarty cache directories\n"
sudo chcon -R -t httpd_sys_rw_content_t vendor/battis/bootstrapsmarty/templates_c
sudo chcon -R -t httpd_sys_rw_content_t vendor/battis/bootstrapsmarty/cache
printf "Updating SELinux context for logging\n"
sudo chcon -R -t httpd_sys_rw_content_t logs
fi
fi
printf "\nDirectory configured.\n"
# OPTIONAL (and convenient)
printf "\nChecking $APACHE_USER crontab...\n"
CRON_ENTRY="$PWD/cron/data-collection.php"
if sudo crontab -l -u $APACHE_USER | grep -q "$CRON_ENTRY"; then
printf "Data collection cron job already scheduled\n"
else
sudo crontab -l -u $APACHE_USER > /tmp/smtech-grading-analytics-crontab
sudo echo "13 0 * * * $CRON_ENTRY" >> /tmp/smtech-grading-analytics-crontab
sudo crontab -u $APACHE_USER /tmp/smtech-grading-analytics-crontab
sudo rm /tmp/smtech-grading-analytics-crontab
printf "Data collection job scheduled via $APACHE_USER crontab\n"
fi
printf "\nPoint your web browser at this directory to complete installation.\n"
printf "\nVisit the account navigation placement of this LTI after installing it in Canvas to complete configuration for data collection\n";