freedomboneeee/src/freedombone-app-kanboard

606 lines
21 KiB
Plaintext
Raw Normal View History

2017-07-25 22:39:27 +02:00
#!/bin/bash
2018-04-08 14:30:21 +02:00
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
2017-07-25 22:39:27 +02:00
#
2018-04-08 14:30:21 +02:00
# Freedom in the Cloud
2017-07-25 22:39:27 +02:00
#
# kanboard kanban
#
# License
# =======
#
2018-01-25 19:35:39 +01:00
# Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
2017-07-25 22:39:27 +02:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
VARIANTS='full full-vim social'
IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1
KANBOARD_DOMAIN_NAME=
KANBOARD_CODE=
KANBOARD_ONION_PORT=8121
KANBOARD_REPO="https://github.com/kanboard/kanboard"
KANBOARD_COMMIT='7a6b1bc3da0af442e02b5a2dc430a4ded8e7c4ee'
KANBOARD_ADMIN_PASSWORD=
2018-05-28 15:47:12 +02:00
KANBOARD_SHORT_DESCRIPTION=$'Simple kanban'
KANBOARD_DESCRIPTION=$'Simple kanban'
KANBOARD_MOBILE_APP_URL=
2017-07-25 22:39:27 +02:00
kanboard_variables=(ONION_ONLY
KANBOARD_DOMAIN_NAME
KANBOARD_CODE
DDNS_PROVIDER
MY_USERNAME)
function logging_on_kanboard {
2017-08-07 14:32:16 +02:00
read_config_param KANBOARD_DOMAIN_NAME
if [ $KANBOARD_DOMAIN_NAME ]; then
kanboard_configfile=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/config.php
if [ -f $kanboard_configfile ]; then
sed -i "s|define('LOG_FILE'.*|define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log');|g" $kanboard_configfile
fi
fi
2017-07-25 22:39:27 +02:00
}
function logging_off_kanboard {
2017-08-07 14:32:16 +02:00
read_config_param KANBOARD_DOMAIN_NAME
if [ $KANBOARD_DOMAIN_NAME ]; then
kanboard_configfile=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/config.php
if [ -f $kanboard_configfile ]; then
sed -i "s|define('LOG_FILE'.*|define('LOG_FILE', '/dev/null');|g" $kanboard_configfile
fi
fi
2017-07-25 22:39:27 +02:00
}
function remove_user_kanboard {
remove_username="$1"
2018-02-27 15:11:56 +01:00
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp kanboard
2017-07-25 22:39:27 +02:00
}
function add_user_kanboard {
new_username="$1"
new_user_password="$2"
2018-02-27 15:11:56 +01:00
"${PROJECT_NAME}-pass" -u "$new_username" -a kanboard -p "$new_user_password"
2017-07-25 22:39:27 +02:00
echo '0'
}
function install_interactive_kanboard {
2018-02-27 15:11:56 +01:00
if [ ! "$ONION_ONLY" ]; then
2017-07-25 22:39:27 +02:00
ONION_ONLY='no'
fi
if [[ $ONION_ONLY != "no" ]]; then
KANBOARD_DOMAIN_NAME='kanboard.local'
else
KANBOARD_DETAILS_COMPLETE=
while [ ! $KANBOARD_DETAILS_COMPLETE ]
do
2018-02-27 15:11:56 +01:00
data=$(mktemp 2>/dev/null)
2018-05-12 18:48:20 +02:00
if [[ $DDNS_PROVIDER == *"freedns"* ]]; then
2017-07-25 22:39:27 +02:00
dialog --backtitle $"Freedombone Configuration" \
--title $"KanBoard Configuration" \
2018-02-27 15:11:56 +01:00
--form $"\\nPlease enter your KanBoard details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt." 13 55 2 \
2017-07-25 22:51:48 +02:00
$"Domain:" 1 1 "$(grep 'KANBOARD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 33 40 \
$"Code:" 2 1 "$(grep 'KANBOARD_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 33 255 \
2018-02-27 15:11:56 +01:00
2> "$data"
2017-07-25 22:39:27 +02:00
else
dialog --backtitle $"Freedombone Configuration" \
--title $"KanBoard Configuration" \
2018-02-27 15:11:56 +01:00
--form $"\\nPlease enter your KanBoard details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt." 13 55 2 \
2017-07-25 22:51:48 +02:00
$"Domain:" 1 1 "$(grep 'KANBOARD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 33 40 \
2018-02-27 15:11:56 +01:00
2> "$data"
2017-07-25 22:39:27 +02:00
fi
sel=$?
case $sel in
2018-02-27 15:11:56 +01:00
1) rm -f "$data"
exit 1;;
255) rm -f "$data"
exit 1;;
2017-07-25 22:39:27 +02:00
esac
2018-02-27 15:11:56 +01:00
KANBOARD_DOMAIN_NAME=$(sed -n 1p < "$data")
if [ "$KANBOARD_DOMAIN_NAME" ]; then
2017-07-25 22:39:27 +02:00
if [[ $KANBOARD_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
KANBOARD_DOMAIN_NAME=""
fi
TEST_DOMAIN_NAME=$KANBOARD_DOMAIN_NAME
validate_domain_name
2018-02-27 15:11:56 +01:00
if [[ "$TEST_DOMAIN_NAME" != "$KANBOARD_DOMAIN_NAME" ]]; then
2017-07-25 22:39:27 +02:00
KANBOARD_DOMAIN_NAME=
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
else
2018-05-12 18:48:20 +02:00
if [[ "$DDNS_PROVIDER" == *"freedns"* ]]; then
2018-02-27 15:11:56 +01:00
KANBOARD_CODE=$(sed -n 2p < "$data")
2017-07-25 22:39:27 +02:00
validate_freedns_code "$KANBOARD_CODE"
2018-02-27 15:11:56 +01:00
if [ ! "$VALID_CODE" ]; then
2017-07-25 22:39:27 +02:00
KANBOARD_DOMAIN_NAME=
fi
fi
fi
fi
if [ $KANBOARD_DOMAIN_NAME ]; then
KANBOARD_DETAILS_COMPLETE="yes"
fi
2018-02-27 15:11:56 +01:00
rm -f "$data"
2017-07-25 22:39:27 +02:00
done
# save the results in the config file
write_config_param "KANBOARD_CODE" "$KANBOARD_CODE"
fi
write_config_param "KANBOARD_DOMAIN_NAME" "$KANBOARD_DOMAIN_NAME"
APP_INSTALLED=1
}
function change_password_kanboard {
curr_username="$1"
new_user_password="$2"
read_config_param 'KANBOARD_DOMAIN_NAME'
2018-02-27 15:11:56 +01:00
"${PROJECT_NAME}-pass" -u "$curr_username" -a kanboard -p "$new_user_password"
2017-07-25 22:39:27 +02:00
}
function kanboard_create_database {
2018-02-27 15:11:56 +01:00
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
KANBOARD_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
2017-07-25 22:39:27 +02:00
else
2018-02-27 15:11:56 +01:00
if [ ! "$KANBOARD_ADMIN_PASSWORD" ]; then
KANBOARD_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
2017-07-25 22:39:27 +02:00
fi
fi
2018-02-27 15:11:56 +01:00
if [ ! "$KANBOARD_ADMIN_PASSWORD" ]; then
2017-07-25 22:39:27 +02:00
return
fi
function_check create_database
2018-02-27 15:11:56 +01:00
create_database kanboard "$KANBOARD_ADMIN_PASSWORD" "$MY_USERNAME"
2017-07-25 22:39:27 +02:00
}
function reconfigure_kanboard {
echo -n ''
}
function upgrade_kanboard {
CURR_KANBOARD_COMMIT=$(get_completion_param "kanboard commit")
if [[ "$CURR_KANBOARD_COMMIT" == "$KANBOARD_COMMIT" ]]; then
return
fi
2018-02-27 15:11:56 +01:00
if grep -q "kanboard domain" "$COMPLETION_FILE"; then
2017-07-25 22:39:27 +02:00
KANBOARD_DOMAIN_NAME=$(get_completion_param "kanboard domain")
fi
# update to the next commit
function_check set_repo_commit
2018-02-27 15:11:56 +01:00
set_repo_commit "/var/www/$KANBOARD_DOMAIN_NAME/htdocs" "kanboard commit" "$KANBOARD_COMMIT" $KANBOARD_REPO
2017-07-25 22:39:27 +02:00
2018-02-27 15:11:56 +01:00
chown -R www-data:www-data "/var/www/${KANBOARD_DOMAIN_NAME}/htdocs"
2017-07-25 22:39:27 +02:00
}
function backup_local_kanboard {
KANBOARD_DOMAIN_NAME='kanboard'
2018-02-27 15:11:56 +01:00
if grep -q "kanboard domain" "$COMPLETION_FILE"; then
2017-07-25 22:39:27 +02:00
KANBOARD_DOMAIN_NAME=$(get_completion_param "kanboard domain")
fi
source_directory=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/backup
2018-02-27 15:11:56 +01:00
if [ ! -d "$source_directory" ]; then
mkdir "$source_directory"
2017-07-25 22:39:27 +02:00
fi
2018-02-27 15:11:56 +01:00
cp -p "/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/config.php" "$source_directory"
2017-07-25 22:39:27 +02:00
function_check suspend_site
2018-02-27 15:11:56 +01:00
suspend_site "${KANBOARD_DOMAIN_NAME}"
2017-07-25 22:39:27 +02:00
function_check backup_directory_to_usb
dest_directory=kanboardconfig
2018-02-27 15:11:56 +01:00
backup_directory_to_usb "$source_directory" "$dest_directory"
2017-07-25 22:39:27 +02:00
source_directory=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/data
dest_directory=kanboardfile
2018-02-27 15:11:56 +01:00
backup_directory_to_usb "$source_directory" "$dest_directory"
2017-07-25 22:39:27 +02:00
function_check backup_database_to_usb
backup_database_to_usb kanboard
function_check restart_site
restart_site
}
function restore_local_kanboard {
2018-02-27 15:11:56 +01:00
if ! grep -q "kanboard domain" "$COMPLETION_FILE"; then
2017-07-25 22:39:27 +02:00
return
fi
KANBOARD_DOMAIN_NAME=$(get_completion_param "kanboard domain")
2018-02-27 15:11:56 +01:00
if [ "$KANBOARD_DOMAIN_NAME" ]; then
2017-07-25 22:39:27 +02:00
echo $"Restoring kanboard"
temp_restore_dir=/root/tempkanboard
kanboard_dir=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs
function_check kanboard_create_database
kanboard_create_database
restore_database kanboard
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir kanboardconfig
if [ -d $temp_restore_dir ]; then
2018-02-27 15:11:56 +01:00
if [ -d "$temp_restore_dir$kanboard_dir/backup" ]; then
cp "$temp_restore_dir$kanboard_dir/backup/config.php" "$kanboard_dir/"
else
2018-02-27 15:11:56 +01:00
cp "$temp_restore_dir/config.php" "$kanboard_dir/"
fi
2018-02-27 15:11:56 +01:00
chown www-data:www-data "$kanboard_dir/config.php"
2017-07-25 22:39:27 +02:00
rm -rf $temp_restore_dir
fi
restore_directory_from_usb $temp_restore_dir kanboardfile
if [ -d $temp_restore_dir ]; then
2018-02-27 15:11:56 +01:00
if [ -d "$temp_restore_dir$kanboard_dir/data" ]; then
cp -rp "$temp_restore_dir$kanboard_dir/data" "$kanboard_dir/"
else
2018-02-27 15:11:56 +01:00
if [ ! -d "$kanboard_dir/data" ]; then
mkdir "$kanboard_dir/data"
fi
2018-03-03 12:49:17 +01:00
cp -rp "$temp_restore_dir/"* "$kanboard_dir/data/"
fi
2018-02-27 15:11:56 +01:00
chown -R www-data:www-data "$kanboard_dir/data"
2017-07-25 22:39:27 +02:00
rm -rf $temp_restore_dir
fi
2018-02-27 15:11:56 +01:00
kanboard_update_after_restore kanboard "${KANBOARD_DOMAIN_NAME}"
2017-07-25 22:39:27 +02:00
echo $"Restore of kanboard complete"
fi
}
function backup_remote_kanboard {
KANBOARD_DOMAIN_NAME='kanboard'
2018-02-27 15:11:56 +01:00
if grep -q "kanboard domain" "$COMPLETION_FILE"; then
2017-07-25 22:39:27 +02:00
KANBOARD_DOMAIN_NAME=$(get_completion_param "kanboard domain")
fi
source_directory=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/backup
2018-02-27 15:11:56 +01:00
if [ ! -d "$source_directory" ]; then
mkdir "$source_directory"
2017-07-25 22:39:27 +02:00
fi
2018-02-27 15:11:56 +01:00
cp -p "/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/config.php" "$source_directory"
2017-07-25 22:39:27 +02:00
function_check suspend_site
2018-02-27 15:11:56 +01:00
suspend_site "${KANBOARD_DOMAIN_NAME}"
2017-07-25 22:39:27 +02:00
function_check backup_directory_to_friend
dest_directory=kanboardconfig
2018-02-27 15:11:56 +01:00
backup_directory_to_friend "$source_directory" "$dest_directory"
2017-07-25 22:39:27 +02:00
source_directory=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/data
dest_directory=kanboardfile
2018-02-27 15:11:56 +01:00
backup_directory_to_friend "$source_directory" "$dest_directory"
2017-07-25 22:39:27 +02:00
function_check backup_database_to_friend
backup_database_to_friend kanboard
function_check restart_site
restart_site
}
function restore_remote_kanboard {
2018-02-27 15:11:56 +01:00
if ! grep -q "kanboard domain" "$COMPLETION_FILE"; then
2017-07-25 22:39:27 +02:00
return
fi
KANBOARD_DOMAIN_NAME=$(get_completion_param "kanboard domain")
2018-02-27 15:11:56 +01:00
if [ "$KANBOARD_DOMAIN_NAME" ]; then
2017-07-25 22:39:27 +02:00
echo $"Restoring kanboard"
temp_restore_dir=/root/tempkanboard
kanboard_dir=/var/www/${KANBOARD_DOMAIN_NAME}/htdocs
function_check kanboard_create_database
kanboard_create_database
function_check restore_database_from_friend
restore_database_from_friend kanboard
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir kanboardconfig
if [ -d $temp_restore_dir ]; then
2018-02-27 15:11:56 +01:00
if [ -d "$temp_restore_dir$kanboard_dir/backup" ]; then
cp "$temp_restore_dir$kanboard_dir/backup/config.php" "$kanboard_dir/"
else
2018-02-27 15:11:56 +01:00
cp "$temp_restore_dir/config.php" "$kanboard_dir/"
fi
2018-02-27 15:11:56 +01:00
chown www-data:www-data "$kanboard_dir/config.php"
2017-07-25 22:39:27 +02:00
rm -rf $temp_restore_dir
fi
restore_directory_from_friend $temp_restore_dir kanboardfile
if [ -d $temp_restore_dir ]; then
2018-02-27 15:11:56 +01:00
if [ -d "$temp_restore_dir$kanboard_dir/data" ]; then
cp -rp "$temp_restore_dir$kanboard_dir/data" "$kanboard_dir/"
else
2018-02-27 15:11:56 +01:00
if [ ! -d "$kanboard_dir/data" ]; then
mkdir "$kanboard_dir/data"
fi
2018-03-03 12:49:17 +01:00
cp -rp "$temp_restore_dir/"* "$kanboard_dir/data/"
fi
2018-02-27 15:11:56 +01:00
chown -R www-data:www-data "$kanboard_dir/data"
2017-07-25 22:39:27 +02:00
rm -rf $temp_restore_dir
fi
2018-02-27 15:11:56 +01:00
kanboard_update_after_restore kanboard "${KANBOARD_DOMAIN_NAME}"
2017-07-25 22:39:27 +02:00
echo $"Restore of kanboard complete"
fi
}
function remove_kanboard {
if [ ${#KANBOARD_DOMAIN_NAME} -eq 0 ]; then
return
fi
read_config_param "KANBOARD_DOMAIN_NAME"
read_config_param "MY_USERNAME"
echo "Removing $KANBOARD_DOMAIN_NAME"
2018-02-27 15:11:56 +01:00
nginx_dissite "$KANBOARD_DOMAIN_NAME"
remove_certs "$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
2018-02-27 15:11:56 +01:00
if [ -d "/var/www/$KANBOARD_DOMAIN_NAME" ]; then
rm -rf "/var/www/$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
fi
2018-02-27 15:11:56 +01:00
if [ -f "/etc/nginx/sites-available/$KANBOARD_DOMAIN_NAME" ]; then
rm "/etc/nginx/sites-available/$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
fi
function_check drop_database
drop_database kanboard
function_check remove_onion_service
remove_onion_service kanboard ${KANBOARD_ONION_PORT}
remove_app kanboard
remove_completion_param install_kanboard
2018-02-27 15:11:56 +01:00
sed -i '/kanboard/d' "$COMPLETION_FILE"
2017-07-25 22:39:27 +02:00
remove_backup_database_local kanboard
function_check remove_ddns_domain
2018-02-27 15:11:56 +01:00
remove_ddns_domain "$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
}
function install_kanboard {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
2018-02-27 15:11:56 +01:00
if [ ! "$KANBOARD_DOMAIN_NAME" ]; then
2017-07-25 22:39:27 +02:00
echo $'No domain name was given for kanboard'
exit 73478
fi
2018-02-27 15:11:56 +01:00
kanboard_hourly_script kanboard "$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
function_check install_mariadb
install_mariadb
function_check get_mariadb_password
get_mariadb_password
function_check repair_databases_script
repair_databases_script
apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
2018-02-27 15:11:56 +01:00
if [ ! -d "/var/www/$KANBOARD_DOMAIN_NAME" ]; then
mkdir "/var/www/$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
fi
2018-02-27 15:11:56 +01:00
if [ ! -d "/var/www/$KANBOARD_DOMAIN_NAME/htdocs" ]; then
2017-07-25 22:39:27 +02:00
if [ -d /repos/kanboard ]; then
2018-02-27 15:11:56 +01:00
mkdir "/var/www/$KANBOARD_DOMAIN_NAME/htdocs"
cp -r -p /repos/kanboard/. "/var/www/$KANBOARD_DOMAIN_NAME/htdocs"
cd "/var/www/$KANBOARD_DOMAIN_NAME/htdocs" || exit 2468274
2017-07-25 22:39:27 +02:00
git pull
else
function_check git_clone
2018-02-27 15:11:56 +01:00
git_clone "$KANBOARD_REPO" "/var/www/$KANBOARD_DOMAIN_NAME/htdocs"
2017-07-25 22:39:27 +02:00
fi
2018-02-27 15:11:56 +01:00
if [ ! -d "/var/www/$KANBOARD_DOMAIN_NAME/htdocs" ]; then
2017-07-25 22:39:27 +02:00
echo $'Unable to clone kanboard repo'
exit 89365
fi
fi
2018-02-27 15:11:56 +01:00
cd "/var/www/$KANBOARD_DOMAIN_NAME/htdocs" || exit 234682642
2017-07-25 22:39:27 +02:00
git checkout $KANBOARD_COMMIT -b $KANBOARD_COMMIT
set_completion_param "kanboard commit" "$KANBOARD_COMMIT"
2018-02-27 15:11:56 +01:00
chmod g+w "/var/www/$KANBOARD_DOMAIN_NAME/htdocs"
chmod a+w "/var/www/$KANBOARD_DOMAIN_NAME/htdocs/data"
chown -R www-data:www-data "/var/www/$KANBOARD_DOMAIN_NAME/htdocs"
2017-07-25 22:39:27 +02:00
function_check kanboard_create_database
kanboard_create_database
if [ ! -f "/etc/aliases" ]; then
touch /etc/aliases
fi
if ! grep -q "www-data: root" /etc/aliases; then
echo 'www-data: root' >> /etc/aliases
fi
function_check add_ddns_domain
2018-02-27 15:11:56 +01:00
add_ddns_domain "$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
KANBOARD_ONION_HOSTNAME=$(add_onion_service kanboard 80 ${KANBOARD_ONION_PORT})
kanboard_nginx_site=/etc/nginx/sites-available/$KANBOARD_DOMAIN_NAME
if [[ $ONION_ONLY == "no" ]]; then
function_check nginx_http_redirect
2018-02-27 15:11:56 +01:00
nginx_http_redirect "$KANBOARD_DOMAIN_NAME" "index index.php"
{ echo 'server {';
echo ' listen 443 ssl;';
echo ' #listen [::]:443 ssl;';
echo " server_name $KANBOARD_DOMAIN_NAME;";
echo ''; } >> "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
function_check nginx_compress
2018-02-27 15:11:56 +01:00
nginx_compress "$KANBOARD_DOMAIN_NAME"
echo '' >> "$kanboard_nginx_site"
echo ' # Security' >> "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
function_check nginx_ssl
2018-02-27 15:11:56 +01:00
nginx_ssl "$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
2018-03-05 19:15:29 +01:00
function_check nginx_security_options
nginx_security_options "$KANBOARD_DOMAIN_NAME"
2018-02-27 15:11:56 +01:00
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
echo '';
echo ' # Logs';
echo ' access_log /dev/null;';
echo ' error_log /dev/null;';
echo '';
echo ' # Root';
echo " root /var/www/$KANBOARD_DOMAIN_NAME/htdocs;";
echo '';
echo ' # Index';
echo ' index index.php;';
echo '';
echo ' # PHP';
echo ' location ~ \.php {';
echo ' include snippets/fastcgi-php.conf;';
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
echo ' fastcgi_read_timeout 30;';
echo ' }';
echo '';
echo ' # Location';
echo ' location / {'; } >> "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
function_check nginx_limits
2018-02-27 15:11:56 +01:00
nginx_limits "$KANBOARD_DOMAIN_NAME" '15m'
{ echo " try_files \$uri \$uri/ @kanboard;";
echo ' }';
echo '';
echo ' # Fancy URLs';
echo ' location @kanboard {';
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
echo ' }';
echo '';
echo ' # Restrict access that is unnecessary anyway';
echo ' location ~ /\.(ht|git) {';
echo ' deny all;';
echo ' }';
echo '}'; } >> "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
else
2018-02-27 15:11:56 +01:00
echo -n '' > "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
fi
2018-02-27 15:11:56 +01:00
{ echo 'server {';
echo " listen 127.0.0.1:$KANBOARD_ONION_PORT default_server;";
echo " server_name $KANBOARD_ONION_HOSTNAME;";
echo ''; } >> "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
function_check nginx_compress
2018-02-27 15:11:56 +01:00
nginx_compress "$KANBOARD_DOMAIN_NAME"
echo '' >> "$kanboard_nginx_site"
2018-03-05 19:15:29 +01:00
function_check nginx_security_options
nginx_security_options "$KANBOARD_DOMAIN_NAME"
2018-02-27 15:11:56 +01:00
{ echo '';
echo ' # Logs';
echo ' access_log /dev/null;';
echo ' error_log /dev/null;';
echo '';
echo ' # Root';
echo " root /var/www/$KANBOARD_DOMAIN_NAME/htdocs;";
echo '';
echo ' # Index';
echo ' index index.php;';
echo '';
echo ' # PHP';
echo ' location ~ \.php {';
echo ' include snippets/fastcgi-php.conf;';
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
echo ' fastcgi_read_timeout 30;';
echo ' }';
echo '';
echo ' # Location';
echo ' location / {'; } >> "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
function_check nginx_limits
2018-02-27 15:11:56 +01:00
nginx_limits "$KANBOARD_DOMAIN_NAME" '15m'
{ echo " try_files \$uri \$uri/ @kanboard;";
echo ' }';
echo '';
echo ' # Fancy URLs';
echo ' location @kanboard {';
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
echo ' }';
echo '';
echo ' # Restrict access that is unnecessary anyway';
echo ' location ~ /\.(ht|git) {';
echo ' deny all;';
echo ' }';
echo '}'; } >> "$kanboard_nginx_site"
2017-07-25 22:39:27 +02:00
function_check configure_php
configure_php
function_check create_site_certificate
2018-02-27 15:11:56 +01:00
create_site_certificate "$KANBOARD_DOMAIN_NAME" 'yes'
2017-07-25 22:39:27 +02:00
# Ensure that the database gets backed up locally, if remote
# backups are not being used
function_check backup_databases_script_header
backup_databases_script_header
function_check backup_database_local
backup_database_local kanboard
function_check nginx_ensite
2018-02-27 15:11:56 +01:00
nginx_ensite "$KANBOARD_DOMAIN_NAME"
2017-07-25 22:39:27 +02:00
# Create the configuration
2018-02-27 15:11:56 +01:00
kanboard_configfile="/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/config.php"
cp "/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/config.default.php" "$kanboard_configfile"
sed -i "s|define('MAIL_FROM'.*|define('MAIL_FROM', '$MY_EMAIL_ADDRESS');|g" "$kanboard_configfile"
sed -i "s|define('DB_DRIVER'.*|define('DB_DRIVER', 'mysql');|g" "$kanboard_configfile"
sed -i "s|define('DB_USERNAME'.*|define('DB_USERNAME', 'root');|g" "$kanboard_configfile"
sed -i "s|define('DB_PASSWORD'.*|define('DB_PASSWORD', '$MARIADB_PASSWORD');|g" "$kanboard_configfile"
sed -i "s|define('DB_HOSTNAME'.*|define('DB_HOSTNAME', 'localhost');|g" "$kanboard_configfile"
sed -i "s|define('DB_NAME'.*|define('DB_NAME', 'kanboard');|g" "$kanboard_configfile"
sed -i "s|define('DB_PORT'.*|define('DB_PORT', null);|g" "$kanboard_configfile"
2017-07-25 22:39:27 +02:00
logging_off_kanboard
2018-02-27 15:11:56 +01:00
initialise_database kanboard "/var/www/${KANBOARD_DOMAIN_NAME}/htdocs/app/Schema/Sql/mysql.sql"
chown -R www-data:www-data "/var/www/${KANBOARD_DOMAIN_NAME}/htdocs"
2017-07-25 23:11:03 +02:00
2018-02-27 15:11:56 +01:00
cd "/var/www/${KANBOARD_DOMAIN_NAME}/htdocs" || exit 24582468
2017-07-25 23:11:03 +02:00
install_composer
2017-07-25 22:39:27 +02:00
systemctl restart mariadb
systemctl restart php7.0-fpm
systemctl restart nginx
2018-02-27 15:11:56 +01:00
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a kanboard -p "$KANBOARD_ADMIN_PASSWORD"
2017-07-25 22:39:27 +02:00
set_completion_param "kanboard domain" "$KANBOARD_DOMAIN_NAME"
APP_INSTALLED=1
}
# NOTE: deliberately there is no "exit 0"