Tidying
This commit is contained in:
parent
5479d49dc9
commit
fa8f96bfdb
|
@ -71,7 +71,7 @@ function mediagoblin_fix_email {
|
||||||
if ! grep -q 'import os' $mgfile; then
|
if ! grep -q 'import os' $mgfile; then
|
||||||
sed -i '/import sys/a import os' $mgfile
|
sed -i '/import sys/a import os' $mgfile
|
||||||
fi
|
fi
|
||||||
sed -i "s|return mhost.sendmail(from_addr, to_addrs, message.as_string())|return os.system(\"echo '\" + message_body + \"' \| mail -s '\" + message['Subject'] + \"' \" + message['To'])|g" $mgfile
|
sed -i "s|return mhost.sendmail(from_addr, to_addrs, message.as_string())|return os.system(\"echo '\" + message_body + \"' \\| mail -s '\" + message['Subject'] + \"' \" + message['To'])|g" $mgfile
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_interactive_mediagoblin {
|
function install_interactive_mediagoblin {
|
||||||
|
@ -92,7 +92,7 @@ function configure_interactive_mediagoblin {
|
||||||
dialog --title $"Mediagoblin" \
|
dialog --title $"Mediagoblin" \
|
||||||
--backtitle $"Freedombone Control Panel" \
|
--backtitle $"Freedombone Control Panel" \
|
||||||
--defaultno \
|
--defaultno \
|
||||||
--yesno $"\nAllow registration of new users?" 10 60
|
--yesno $"\\nAllow registration of new users?" 10 60
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
0)
|
0)
|
||||||
|
@ -139,7 +139,7 @@ function reconfigure_mediagoblin {
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_mediagoblin {
|
function upgrade_mediagoblin {
|
||||||
CURR_MEDIAGOBLIN_COMMIT=$(cat $COMPLETION_FILE | grep "mediagoblin commit" | awk -F ':' '{print $2}')
|
CURR_MEDIAGOBLIN_COMMIT=$(grep "mediagoblin commit" "$COMPLETION_FILE" | awk -F ':' '{print $2}')
|
||||||
if [[ "$CURR_MEDIAGOBLIN_COMMIT" != "$MEDIAGOBLIN_COMMIT" ]]; then
|
if [[ "$CURR_MEDIAGOBLIN_COMMIT" != "$MEDIAGOBLIN_COMMIT" ]]; then
|
||||||
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
|
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && git stash && git pull" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && git stash && git pull" - mediagoblin
|
||||||
|
@ -182,6 +182,7 @@ function restore_local_mediagoblin {
|
||||||
else
|
else
|
||||||
cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
|
cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
function_check restore_directory_from_usb
|
function_check restore_directory_from_usb
|
||||||
set_user_permissions
|
set_user_permissions
|
||||||
|
@ -195,6 +196,7 @@ function restore_local_mediagoblin {
|
||||||
else
|
else
|
||||||
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
|
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
function_check set_user_permissions
|
function_check set_user_permissions
|
||||||
set_user_permissions
|
set_user_permissions
|
||||||
|
@ -214,24 +216,25 @@ function backup_remote_mediagoblin {
|
||||||
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
|
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
|
||||||
if [ -d /etc/mediagoblin ]; then
|
if [ -d /etc/mediagoblin ]; then
|
||||||
echo $"Backing up mediagoblin"
|
echo $"Backing up mediagoblin"
|
||||||
backup_directory_to_friend $MEDIAGOBLIN_BASE_DIR mediagoblin
|
backup_directory_to_friend "$MEDIAGOBLIN_BASE_DIR" mediagoblin
|
||||||
backup_directory_to_friend /var/lib/mediagoblin mediagoblindata
|
backup_directory_to_friend /var/lib/mediagoblin mediagoblindata
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_remote_mediagoblin {
|
function restore_remote_mediagoblin {
|
||||||
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
|
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
|
||||||
if [ -d $SERVER_DIRECTORY/backup/mediagoblin ]; then
|
if [ -d "$SERVER_DIRECTORY/backup/mediagoblin" ]; then
|
||||||
temp_restore_dir=/root/tempmediagoblin
|
temp_restore_dir=/root/tempmediagoblin
|
||||||
function_check get_completion_param
|
function_check get_completion_param
|
||||||
MEDIAGOBLIN_DOMAIN_NAME=$(get_completion_param "mediagoblin domain")
|
MEDIAGOBLIN_DOMAIN_NAME=$(get_completion_param "mediagoblin domain")
|
||||||
function_check restore_directory_from_friend
|
function_check restore_directory_from_friend
|
||||||
restore_directory_from_friend $temp_restore_dir mediagoblin
|
restore_directory_from_friend $temp_restore_dir mediagoblin
|
||||||
if [ -d ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR ]; then
|
if [ -d "${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR" ]; then
|
||||||
cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
|
cp -r "${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/*" "$MEDIAGOBLIN_BASE_DIR/"
|
||||||
else
|
else
|
||||||
cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
|
cp -r "${temp_restore_dir}/*" "$MEDIAGOBLIN_BASE_DIR/"
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 264824
|
exit 264824
|
||||||
fi
|
fi
|
||||||
|
@ -241,12 +244,13 @@ function restore_remote_mediagoblin {
|
||||||
else
|
else
|
||||||
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
|
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 268492
|
exit 268492
|
||||||
fi
|
fi
|
||||||
rm -rf ${temp_restore_dir}
|
rm -rf ${temp_restore_dir}
|
||||||
rm -rf ${temp_restore_dir}2
|
rm -rf ${temp_restore_dir}2
|
||||||
chown -hR mediagoblin:www-data $MEDIAGOBLIN_BASE_DIR
|
chown -hR mediagoblin:www-data "$MEDIAGOBLIN_BASE_DIR"
|
||||||
chown -hR mediagoblin:www-data /var/lib/mediagoblin
|
chown -hR mediagoblin:www-data /var/lib/mediagoblin
|
||||||
chmod -R g+wx /var/lib/mediagoblin
|
chmod -R g+wx /var/lib/mediagoblin
|
||||||
fi
|
fi
|
||||||
|
@ -264,17 +268,17 @@ function remove_mediagoblin {
|
||||||
|
|
||||||
function_check remove_onion_service
|
function_check remove_onion_service
|
||||||
remove_onion_service mediagoblin ${MEDIAGOBLIN_ONION_PORT}
|
remove_onion_service mediagoblin ${MEDIAGOBLIN_ONION_PORT}
|
||||||
nginx_dissite $MEDIAGOBLIN_DOMAIN_NAME
|
nginx_dissite "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
remove_certs $MEDIAGOBLIN_DOMAIN_NAME
|
remove_certs "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
if [ -d /var/lib/mediagoblin ]; then
|
if [ -d /var/lib/mediagoblin ]; then
|
||||||
rm -rf /var/lib/mediagoblin
|
rm -rf /var/lib/mediagoblin
|
||||||
fi
|
fi
|
||||||
if [ -d $MEDIAGOBLIN_BASE_DIR ]; then
|
if [ -d "$MEDIAGOBLIN_BASE_DIR" ]; then
|
||||||
rm -rf $MEDIAGOBLIN_BASE_DIR
|
rm -rf "$MEDIAGOBLIN_BASE_DIR"
|
||||||
fi
|
fi
|
||||||
remove_completion_param "install_mediagoblin"
|
remove_completion_param "install_mediagoblin"
|
||||||
remove_completion_param "mediagoblin domain"
|
remove_completion_param "mediagoblin domain"
|
||||||
sed -i '/mediagoblin/d' $COMPLETION_FILE
|
sed -i '/mediagoblin/d' "$COMPLETION_FILE"
|
||||||
|
|
||||||
remove_nodejs mediagoblin
|
remove_nodejs mediagoblin
|
||||||
|
|
||||||
|
@ -282,11 +286,11 @@ function remove_mediagoblin {
|
||||||
userdel -r mediagoblin
|
userdel -r mediagoblin
|
||||||
|
|
||||||
function_check remove_ddns_domain
|
function_check remove_ddns_domain
|
||||||
remove_ddns_domain $MEDIAGOBLIN_DOMAIN_NAME
|
remove_ddns_domain "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_mediagoblin {
|
function install_mediagoblin {
|
||||||
if [ ! $MEDIAGOBLIN_DOMAIN_NAME ]; then
|
if [ ! "$MEDIAGOBLIN_DOMAIN_NAME" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -304,17 +308,17 @@ function install_mediagoblin {
|
||||||
useradd -c "GNU MediaGoblin system account" -d /var/lib/mediagoblin -m -r -g www-data mediagoblin
|
useradd -c "GNU MediaGoblin system account" -d /var/lib/mediagoblin -m -r -g www-data mediagoblin
|
||||||
usermod --append -G mediagoblin mediagoblin
|
usermod --append -G mediagoblin mediagoblin
|
||||||
mkdir -p /var/lib/mediagoblin
|
mkdir -p /var/lib/mediagoblin
|
||||||
mkdir -p $MEDIAGOBLIN_BASE_DIR
|
mkdir -p "$MEDIAGOBLIN_BASE_DIR"
|
||||||
chown -hR mediagoblin:www-data $MEDIAGOBLIN_BASE_DIR
|
chown -hR mediagoblin:www-data "$MEDIAGOBLIN_BASE_DIR"
|
||||||
chown -hR mediagoblin:www-data /var/lib/mediagoblin
|
chown -hR mediagoblin:www-data /var/lib/mediagoblin
|
||||||
chmod -R g+wx /var/lib/mediagoblin
|
chmod -R g+wx /var/lib/mediagoblin
|
||||||
|
|
||||||
if [ -d /repos/mediagoblin ]; then
|
if [ -d /repos/mediagoblin ]; then
|
||||||
mkdir -p $MEDIAGOBLIN_BASE_DIR/mediagoblin
|
mkdir -p "$MEDIAGOBLIN_BASE_DIR/mediagoblin"
|
||||||
cp -r -p /repos/mediagoblin/. $MEDIAGOBLIN_BASE_DIR/mediagoblin
|
cp -r -p /repos/mediagoblin/. "$MEDIAGOBLIN_BASE_DIR/mediagoblin"
|
||||||
cd $MEDIAGOBLIN_BASE_DIR/mediagoblin
|
cd "$MEDIAGOBLIN_BASE_DIR/mediagoblin" || exit 347593563
|
||||||
git pull
|
git pull
|
||||||
chown -R mediagoblin:mediagoblin $MEDIAGOBLIN_BASE_DIR/mediagoblin
|
chown -R mediagoblin:mediagoblin "$MEDIAGOBLIN_BASE_DIR/mediagoblin"
|
||||||
else
|
else
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR && git clone $MEDIAGOBLIN_REPO $MEDIAGOBLIN_BASE_DIR/mediagoblin" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR && git clone $MEDIAGOBLIN_REPO $MEDIAGOBLIN_BASE_DIR/mediagoblin" - mediagoblin
|
||||||
fi
|
fi
|
||||||
|
@ -340,7 +344,7 @@ function install_mediagoblin {
|
||||||
gstreamer1.0-plugins-ugly \
|
gstreamer1.0-plugins-ugly \
|
||||||
gstreamer1.0-libav \
|
gstreamer1.0-libav \
|
||||||
python-gst-1.0 python3-gst-1.0
|
python-gst-1.0 python3-gst-1.0
|
||||||
cd $MEDIAGOBLIN_BASE_DIR/mediagoblin
|
cd "$MEDIAGOBLIN_BASE_DIR/mediagoblin" || exit 76345672472
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin && echo '[[mediagoblin.media_types.video]]' | tee -a mediagoblin_local.ini" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin && echo '[[mediagoblin.media_types.video]]' | tee -a mediagoblin_local.ini" - mediagoblin
|
||||||
|
|
||||||
# Audio plugin
|
# Audio plugin
|
||||||
|
@ -349,14 +353,14 @@ function install_mediagoblin {
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin && echo '[[mediagoblin.media_types.audio]]' | tee -a mediagoblin_local.ini" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin && echo '[[mediagoblin.media_types.audio]]' | tee -a mediagoblin_local.ini" - mediagoblin
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin && bin/pip install scikits.audiolab" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin && bin/pip install scikits.audiolab" - mediagoblin
|
||||||
|
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
MEDIAGOBLIN_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
MEDIAGOBLIN_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
if [ ! $MEDIAGOBLIN_ADMIN_PASSWORD ]; then
|
if [ ! "$MEDIAGOBLIN_ADMIN_PASSWORD" ]; then
|
||||||
MEDIAGOBLIN_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
MEDIAGOBLIN_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a mediagoblin -p "$MEDIAGOBLIN_ADMIN_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a mediagoblin -p "$MEDIAGOBLIN_ADMIN_PASSWORD"
|
||||||
|
|
||||||
MEDIAGOBLIN_ONION_HOSTNAME=$(add_onion_service mediagoblin 80 ${MEDIAGOBLIN_ONION_PORT})
|
MEDIAGOBLIN_ONION_HOSTNAME=$(add_onion_service mediagoblin 80 ${MEDIAGOBLIN_ONION_PORT})
|
||||||
set_completion_param "mediagoblin domain" "${MEDIAGOBLIN_DOMAIN_NAME}"
|
set_completion_param "mediagoblin domain" "${MEDIAGOBLIN_DOMAIN_NAME}"
|
||||||
|
@ -365,157 +369,157 @@ function install_mediagoblin {
|
||||||
|
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $MEDIAGOBLIN_DOMAIN_NAME
|
nginx_http_redirect "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
echo 'server {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo ' include /etc/nginx/mime.types;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' include /etc/nginx/mime.types;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' autoindex off;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' autoindex off;';
|
||||||
echo ' default_type application/octet-stream;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' default_type application/octet-stream;';
|
||||||
echo ' sendfile on;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' sendfile on;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ''; } >> "/etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $MEDIAGOBLIN_DOMAIN_NAME
|
nginx_ssl "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $MEDIAGOBLIN_DOMAIN_NAME
|
nginx_disable_sniffing "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $MEDIAGOBLIN_DOMAIN_NAME 800m
|
nginx_limits "$MEDIAGOBLIN_DOMAIN_NAME" 800m
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
{ echo '';
|
||||||
echo ' client_header_timeout 10m;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' client_header_timeout 10m;';
|
||||||
echo ' client_body_timeout 10m;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' client_body_timeout 10m;';
|
||||||
echo ' send_timeout 10m;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' send_timeout 10m;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' fastcgi_read_timeout 600;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_read_timeout 600;';
|
||||||
echo ' fastcgi_send_timeout 600;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_send_timeout 600;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' gzip on;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip on;';
|
||||||
echo ' gzip_min_length 1024;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip_min_length 1024;';
|
||||||
echo ' gzip_buffers 4 32k;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip_buffers 4 32k;';
|
||||||
echo ' gzip_types text/plain application/x-javascript text/javascript text/xml text/css;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip_types text/plain application/x-javascript text/javascript text/xml text/css;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo " server_name $MEDIAGOBLIN_DOMAIN_NAME;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " server_name $MEDIAGOBLIN_DOMAIN_NAME;";
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
|
|
||||||
echo ' location /mgoblin_static/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /mgoblin_static/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin/static/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin/static/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location /mgoblin_media/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /mgoblin_media/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/media/public/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/media/public/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location /theme_static/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /theme_static/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/theme_static/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/theme_static/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location /plugin_static/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /plugin_static/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/plugin_static/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/plugin_static/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location / {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location / {';
|
||||||
echo " fastcgi_pass 127.0.0.1:$MEDIAGOBLIN_PORT;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " fastcgi_pass 127.0.0.1:$MEDIAGOBLIN_PORT;";
|
||||||
echo ' include /etc/nginx/fastcgi_params;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' include /etc/nginx/fastcgi_params;';
|
||||||
echo ' fastcgi_param PATH_INFO $fastcgi_script_name;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " fastcgi_param PATH_INFO \$fastcgi_script_name;";
|
||||||
echo ' fastcgi_param SCRIPT_NAME "";' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_param SCRIPT_NAME "";';
|
||||||
echo ' fastcgi_read_timeout 30;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '}' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '}'; } >> "/etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
else
|
else
|
||||||
echo -n '' > /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo -n '' > "/etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:${MEDIAGOBLIN_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " listen 127.0.0.1:${MEDIAGOBLIN_ONION_PORT} default_server;";
|
||||||
echo ' include /etc/nginx/mime.types;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' include /etc/nginx/mime.types;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' autoindex off;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' autoindex off;';
|
||||||
echo ' default_type application/octet-stream;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' default_type application/octet-stream;';
|
||||||
echo ' sendfile on;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' sendfile on;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ''; } >> "/etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $MEDIAGOBLIN_DOMAIN_NAME
|
nginx_disable_sniffing "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $MEDIAGOBLIN_DOMAIN_NAME 800m
|
nginx_limits "$MEDIAGOBLIN_DOMAIN_NAME" 800m
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
{ echo '';
|
||||||
echo ' client_header_timeout 10m;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' client_header_timeout 10m;';
|
||||||
echo ' client_body_timeout 10m;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' client_body_timeout 10m;';
|
||||||
echo ' send_timeout 10m;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' send_timeout 10m;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' fastcgi_read_timeout 600;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_read_timeout 600;';
|
||||||
echo ' fastcgi_send_timeout 600;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_send_timeout 600;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' gzip on;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip on;';
|
||||||
echo ' gzip_min_length 1024;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip_min_length 1024;';
|
||||||
echo ' gzip_buffers 4 32k;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip_buffers 4 32k;';
|
||||||
echo ' gzip_types text/plain application/x-javascript text/javascript text/xml text/css;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' gzip_types text/plain application/x-javascript text/javascript text/xml text/css;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo " server_name $MEDIAGOBLIN_ONION_HOSTNAME;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " server_name $MEDIAGOBLIN_ONION_HOSTNAME;";
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
|
|
||||||
echo ' location /mgoblin_static/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /mgoblin_static/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin/static/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin/static/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location /mgoblin_media/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /mgoblin_media/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/media/public/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/media/public/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location /theme_static/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /theme_static/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/theme_static/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/theme_static/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location /plugin_static/ {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location /plugin_static/ {';
|
||||||
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/plugin_static/;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " alias $MEDIAGOBLIN_BASE_DIR/mediagoblin/user_dev/plugin_static/;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location / {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' location / {';
|
||||||
echo " fastcgi_pass 127.0.0.1:$MEDIAGOBLIN_PORT;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " fastcgi_pass 127.0.0.1:$MEDIAGOBLIN_PORT;";
|
||||||
echo ' include /etc/nginx/fastcgi_params;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' include /etc/nginx/fastcgi_params;';
|
||||||
echo ' fastcgi_param PATH_INFO $fastcgi_script_name;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo " fastcgi_param PATH_INFO \$fastcgi_script_name;";
|
||||||
echo ' fastcgi_param SCRIPT_NAME "";' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_param SCRIPT_NAME "";';
|
||||||
echo ' fastcgi_read_timeout 30;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '}' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
|
echo '}'; } >> "/etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
|
|
||||||
echo '[Unit]' > /etc/systemd/system/mediagoblin.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=Media service' >> /etc/systemd/system/mediagoblin.service
|
echo 'Description=Media service';
|
||||||
echo 'Requires=network.target' >> /etc/systemd/system/mediagoblin.service
|
echo 'Requires=network.target';
|
||||||
echo 'After=network.target' >> /etc/systemd/system/mediagoblin.service
|
echo 'After=network.target';
|
||||||
echo '' >> /etc/systemd/system/mediagoblin.service
|
echo '';
|
||||||
echo '[Service]' >> /etc/systemd/system/mediagoblin.service
|
echo '[Service]';
|
||||||
echo 'Type=simple' >> /etc/systemd/system/mediagoblin.service
|
echo 'Type=simple';
|
||||||
echo 'User=mediagoblin' >> /etc/systemd/system/mediagoblin.service
|
echo 'User=mediagoblin';
|
||||||
echo 'Group=mediagoblin' >> /etc/systemd/system/mediagoblin.service
|
echo 'Group=mediagoblin';
|
||||||
echo "WorkingDirectory=$MEDIAGOBLIN_BASE_DIR/mediagoblin/" >> /etc/systemd/system/mediagoblin.service
|
echo "WorkingDirectory=$MEDIAGOBLIN_BASE_DIR/mediagoblin/";
|
||||||
echo "ExecStart=$MEDIAGOBLIN_BASE_DIR/mediagoblin/lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=$MEDIAGOBLIN_PORT" >> /etc/systemd/system/mediagoblin.service
|
echo "ExecStart=$MEDIAGOBLIN_BASE_DIR/mediagoblin/lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=$MEDIAGOBLIN_PORT";
|
||||||
echo "Environment=MEDIAGOBLIN_CONFIG=$MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini CELERY_ALWAYS_EAGER=true" >> /etc/systemd/system/mediagoblin.service
|
echo "Environment=MEDIAGOBLIN_CONFIG=$MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini CELERY_ALWAYS_EAGER=true";
|
||||||
echo 'Restart=always' >> /etc/systemd/system/mediagoblin.service
|
echo 'Restart=always';
|
||||||
echo 'RestartSec=10' >> /etc/systemd/system/mediagoblin.service
|
echo 'RestartSec=10';
|
||||||
echo '' >> /etc/systemd/system/mediagoblin.service
|
echo '';
|
||||||
echo '[Install]' >> /etc/systemd/system/mediagoblin.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/mediagoblin.service
|
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/mediagoblin.service
|
||||||
chmod +x /etc/systemd/system/mediagoblin.service
|
chmod +x /etc/systemd/system/mediagoblin.service
|
||||||
|
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg dbupdate" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg dbupdate" - mediagoblin
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg adduser --username $MY_USERNAME --password $MY_USERNAME $MEDIAGOBLIN_ADMIN_PASSWORD" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg adduser --username $MY_USERNAME --password $MY_USERNAME $MEDIAGOBLIN_ADMIN_PASSWORD" - mediagoblin
|
||||||
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg makeadmin $MY_USERNAME" - mediagoblin
|
su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg makeadmin $MY_USERNAME" - mediagoblin
|
||||||
|
|
||||||
sed -i 's|email_debug_mode.*|email_debug_mode = false|g' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
sed -i 's|email_debug_mode.*|email_debug_mode = false|g' "$MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini"
|
||||||
sed -i "s|email_sender_address.*|email_sender_address = \"noreply@${DEFAULT_DOMAIN_NAME}\"|g" $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
sed -i "s|email_sender_address.*|email_sender_address = \"noreply@${DEFAULT_DOMAIN_NAME}\"|g" "$MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini"
|
||||||
|
|
||||||
sed -i 's|allow_reporting.*|allow_reporting = false|g' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
sed -i 's|allow_reporting.*|allow_reporting = false|g' "$MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini"
|
||||||
|
|
||||||
if ! grep -q '[[[skip_transcode]]]' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini; then
|
if ! grep -q '[[[skip_transcode]]]' "$MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini"; then
|
||||||
echo '[[[skip_transcode]]]' >> $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
{ echo '[[[skip_transcode]]]';
|
||||||
echo 'mime_types = video/webm, video/ogg, video/mp4, audio/ogg, application/ogg, application/x-annodex' >> $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
echo 'mime_types = video/webm, video/ogg, video/mp4, audio/ogg, application/ogg, application/x-annodex';
|
||||||
echo 'container_formats = Matroska, Ogg, ISO MP4/M4A' >> $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
echo 'container_formats = Matroska, Ogg, ISO MP4/M4A';
|
||||||
echo 'video_codecs = VP8 video, VP9 video, Theora, H.264, H.264 / AVC, MPEG-4 video' >> $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
echo 'video_codecs = VP8 video, VP9 video, Theora, H.264, H.264 / AVC, MPEG-4 video';
|
||||||
echo 'audio_codecs = Vorbis, MPEG-4 AAC' >> $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
echo 'audio_codecs = Vorbis, MPEG-4 AAC';
|
||||||
echo 'dimensions_match = false' >> $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
|
echo 'dimensions_match = false'; } >> "$MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl enable mediagoblin
|
systemctl enable mediagoblin
|
||||||
|
@ -529,18 +533,18 @@ function install_mediagoblin {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate $MEDIAGOBLIN_DOMAIN_NAME 'yes'
|
create_site_certificate "$MEDIAGOBLIN_DOMAIN_NAME" 'yes'
|
||||||
|
|
||||||
function_check configure_php
|
function_check configure_php
|
||||||
configure_php
|
configure_php
|
||||||
|
|
||||||
nginx_ensite $MEDIAGOBLIN_DOMAIN_NAME
|
nginx_ensite "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
|
|
||||||
systemctl restart php7.0-fpm
|
systemctl restart php7.0-fpm
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
function_check add_ddns_domain
|
function_check add_ddns_domain
|
||||||
add_ddns_domain $MEDIAGOBLIN_DOMAIN_NAME
|
add_ddns_domain "$MEDIAGOBLIN_DOMAIN_NAME"
|
||||||
|
|
||||||
chown -hR mediagoblin:www-data /var/lib/mediagoblin
|
chown -hR mediagoblin:www-data /var/lib/mediagoblin
|
||||||
chmod -R g+wx /var/lib/mediagoblin
|
chmod -R g+wx /var/lib/mediagoblin
|
||||||
|
|
|
@ -58,19 +58,19 @@ function logging_off_movim {
|
||||||
function remove_user_movim {
|
function remove_user_movim {
|
||||||
remove_username="$1"
|
remove_username="$1"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $remove_username --rmapp movim
|
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp movim
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_user_movim {
|
function add_user_movim {
|
||||||
new_username="$1"
|
new_username="$1"
|
||||||
new_user_password="$2"
|
new_user_password="$2"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $new_username -a movim -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$new_username" -a movim -p "$new_user_password"
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_interactive_movim {
|
function install_interactive_movim {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -80,39 +80,38 @@ function install_interactive_movim {
|
||||||
MOVIM_DETAILS_COMPLETE=
|
MOVIM_DETAILS_COMPLETE=
|
||||||
while [ ! $MOVIM_DETAILS_COMPLETE ]
|
while [ ! $MOVIM_DETAILS_COMPLETE ]
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"Movim Configuration" \
|
--title $"Movim Configuration" \
|
||||||
--form $"\nPlease enter your Movim details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 12 65 2 \
|
--form $"\\nPlease enter your Movim details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 12 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'MOVIM_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
$"Domain:" 1 1 "$(grep 'MOVIM_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||||
$"Code:" 2 1 "$(grep 'MOVIM_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
|
$"Code:" 2 1 "$(grep 'MOVIM_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
|
||||||
2> $data
|
2> "$data"
|
||||||
else
|
else
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"Movim Configuration" \
|
--title $"Movim Configuration" \
|
||||||
--form $"\nPlease enter your Movim details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 12 65 2 \
|
--form $"\\nPlease enter your Movim details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 12 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'MOVIM_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
$"Domain:" 1 1 "$(grep 'MOVIM_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||||
2> $data
|
2> "$data"
|
||||||
fi
|
fi
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) exit 1;;
|
||||||
255) exit 1;;
|
255) exit 1;;
|
||||||
esac
|
esac
|
||||||
MOVIM_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
MOVIM_DOMAIN_NAME=$(sed -n 1p < "$data")
|
||||||
if [ $MOVIM_DOMAIN_NAME ]; then
|
if [ "$MOVIM_DOMAIN_NAME" ]; then
|
||||||
TEST_DOMAIN_NAME=$MOVIM_DOMAIN_NAME
|
TEST_DOMAIN_NAME=$MOVIM_DOMAIN_NAME
|
||||||
validate_domain_name
|
validate_domain_name
|
||||||
if [[ $TEST_DOMAIN_NAME != $MOVIM_DOMAIN_NAME ]]; then
|
if [[ "$TEST_DOMAIN_NAME" != "$MOVIM_DOMAIN_NAME" ]]; then
|
||||||
MOVIM_DOMAIN_NAME=
|
MOVIM_DOMAIN_NAME=
|
||||||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||||||
else
|
else
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
MOVIM_CODE=$(cat $data | sed -n 2p)
|
MOVIM_CODE=$(sed -n 2p < "$data")
|
||||||
validate_freedns_code "$MOVIM_CODE"
|
validate_freedns_code "$MOVIM_CODE"
|
||||||
if [ ! $VALID_CODE ]; then
|
if [ ! "$VALID_CODE" ]; then
|
||||||
MOVIM_DOMAIN_NAME=
|
MOVIM_DOMAIN_NAME=
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -121,6 +120,7 @@ function install_interactive_movim {
|
||||||
if [ $MOVIM_DOMAIN_NAME ]; then
|
if [ $MOVIM_DOMAIN_NAME ]; then
|
||||||
MOVIM_DETAILS_COMPLETE="yes"
|
MOVIM_DETAILS_COMPLETE="yes"
|
||||||
fi
|
fi
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
|
|
||||||
# save the results in the config file
|
# save the results in the config file
|
||||||
|
@ -136,23 +136,23 @@ function change_password_movim {
|
||||||
|
|
||||||
read_config_param 'MOVIM_DOMAIN_NAME'
|
read_config_param 'MOVIM_DOMAIN_NAME'
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u "$curr_username" -a movim -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a movim -p "$new_user_password"
|
||||||
}
|
}
|
||||||
|
|
||||||
function movim_create_database {
|
function movim_create_database {
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
MOVIM_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
MOVIM_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
if [ ! $MOVIM_ADMIN_PASSWORD ]; then
|
if [ ! "$MOVIM_ADMIN_PASSWORD" ]; then
|
||||||
MOVIM_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
MOVIM_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! $MOVIM_ADMIN_PASSWORD ]; then
|
if [ ! "$MOVIM_ADMIN_PASSWORD" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check create_database
|
function_check create_database
|
||||||
create_database movim "$MOVIM_ADMIN_PASSWORD" $MY_USERNAME
|
create_database movim "$MOVIM_ADMIN_PASSWORD" "$MY_USERNAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function reconfigure_movim {
|
function reconfigure_movim {
|
||||||
|
@ -165,35 +165,35 @@ function upgrade_movim {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "movim domain" $COMPLETION_FILE; then
|
if grep -q "movim domain" "$COMPLETION_FILE"; then
|
||||||
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update to the next commit
|
# update to the next commit
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit /var/www/$MOVIM_DOMAIN_NAME/htdocs "movim commit" "$MOVIM_COMMIT" $MOVIM_REPO
|
set_repo_commit "/var/www/$MOVIM_DOMAIN_NAME/htdocs" "movim commit" "$MOVIM_COMMIT" "$MOVIM_REPO"
|
||||||
|
|
||||||
cd /var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
cd "/var/www/${MOVIM_DOMAIN_NAME}/htdocs" || exit 6734824522
|
||||||
php composer.phar install
|
php composer.phar install
|
||||||
php mud.php db --set
|
php mud.php db --set
|
||||||
chown -R www-data:www-data /var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
chown -R www-data:www-data "/var/www/${MOVIM_DOMAIN_NAME}/htdocs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function backup_local_movim {
|
function backup_local_movim {
|
||||||
MOVIM_DOMAIN_NAME='movim'
|
MOVIM_DOMAIN_NAME='movim'
|
||||||
if grep -q "movim domain" $COMPLETION_FILE; then
|
if grep -q "movim domain" "$COMPLETION_FILE"; then
|
||||||
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source_directory=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
source_directory="/var/www/${MOVIM_DOMAIN_NAME}/htdocs"
|
||||||
if [ -d $source_directory ]; then
|
if [ -d "$source_directory" ]; then
|
||||||
dest_directory=movim
|
dest_directory=movim
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${MOVIM_DOMAIN_NAME}
|
suspend_site "${MOVIM_DOMAIN_NAME}"
|
||||||
|
|
||||||
function_check backup_directory_to_usb
|
function_check backup_directory_to_usb
|
||||||
backup_directory_to_usb $source_directory $dest_directory
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
function_check backup_database_to_usb
|
function_check backup_database_to_usb
|
||||||
backup_database_to_usb movim
|
backup_database_to_usb movim
|
||||||
|
@ -204,28 +204,28 @@ function backup_local_movim {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_local_movim {
|
function restore_local_movim {
|
||||||
if ! grep -q "movim domain" $COMPLETION_FILE; then
|
if ! grep -q "movim domain" "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
||||||
if [ $MOVIM_DOMAIN_NAME ]; then
|
if [ "$MOVIM_DOMAIN_NAME" ]; then
|
||||||
echo $"Restoring movim"
|
echo $"Restoring movim"
|
||||||
temp_restore_dir=/root/tempmovim
|
temp_restore_dir=/root/tempmovim
|
||||||
movim_dir=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
movim_dir=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
||||||
# stop the daemons
|
# stop the daemons
|
||||||
cd $movim_dir
|
cd "$movim_dir" || exit 7856724252
|
||||||
su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
|
su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
|
||||||
|
|
||||||
function_check movim_create_database
|
function_check movim_create_database
|
||||||
movim_create_database
|
movim_create_database
|
||||||
|
|
||||||
restore_database movim ${MOVIM_DOMAIN_NAME}
|
restore_database movim "${MOVIM_DOMAIN_NAME}"
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
MARIADB_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
|
||||||
cd /var/www/$MOVIM_DOMAIN_NAME/htdocs/config
|
cd "/var/www/$MOVIM_DOMAIN_NAME/htdocs/config" || exit 2468724682
|
||||||
sed -i "s|'password'.*|'password' => '$MARIADB_PASSWORD',|g" db.inc.php
|
sed -i "s|'password'.*|'password' => '$MARIADB_PASSWORD',|g" db.inc.php
|
||||||
MARIADB_PASSWORD=
|
MARIADB_PASSWORD=
|
||||||
|
|
||||||
|
@ -234,18 +234,18 @@ function restore_local_movim {
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_remote_movim {
|
function backup_remote_movim {
|
||||||
if grep -q "movim domain" $COMPLETION_FILE; then
|
if grep -q "movim domain" "$COMPLETION_FILE"; then
|
||||||
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
||||||
temp_backup_dir=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
temp_backup_dir=/var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
||||||
if [ -d $temp_backup_dir ]; then
|
if [ -d "$temp_backup_dir" ]; then
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${MOVIM_DOMAIN_NAME}
|
suspend_site "${MOVIM_DOMAIN_NAME}"
|
||||||
|
|
||||||
function_check backup_database_to_friend
|
function_check backup_database_to_friend
|
||||||
backup_database_to_friend movim
|
backup_database_to_friend movim
|
||||||
|
|
||||||
function_check backup_directory_to_friend
|
function_check backup_directory_to_friend
|
||||||
backup_directory_to_friend $temp_backup_dir movim
|
backup_directory_to_friend "$temp_backup_dir" movim
|
||||||
|
|
||||||
function_check restart_site
|
function_check restart_site
|
||||||
restart_site
|
restart_site
|
||||||
|
@ -256,25 +256,25 @@ function backup_remote_movim {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_remote_movim {
|
function restore_remote_movim {
|
||||||
if grep -q "movim domain" $COMPLETION_FILE; then
|
if grep -q "movim domain" "$COMPLETION_FILE"; then
|
||||||
echo $"Restoring movim"
|
echo $"Restoring movim"
|
||||||
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
MOVIM_DOMAIN_NAME=$(get_completion_param "movim domain")
|
||||||
|
|
||||||
# stop the daemons
|
# stop the daemons
|
||||||
cd /var/www/${MOVIM_DOMAIN_NAME}/htdocs
|
cd "/var/www/${MOVIM_DOMAIN_NAME}/htdocs" || exit 524792846827
|
||||||
su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
|
su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
|
||||||
|
|
||||||
function_check movim_create_database
|
function_check movim_create_database
|
||||||
movim_create_database
|
movim_create_database
|
||||||
|
|
||||||
function_check restore_database_from_friend
|
function_check restore_database_from_friend
|
||||||
restore_database_from_friend movim ${MOVIM_DOMAIN_NAME}
|
restore_database_from_friend movim "${MOVIM_DOMAIN_NAME}"
|
||||||
if [ -d /root/tempmovim ]; then
|
if [ -d /root/tempmovim ]; then
|
||||||
rm -rf /root/tempmovim
|
rm -rf /root/tempmovim
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
MARIADB_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
|
||||||
cd /var/www/$MOVIM_DOMAIN_NAME/htdocs/config
|
cd "/var/www/$MOVIM_DOMAIN_NAME/htdocs/config" || exit 4242462487
|
||||||
sed -i "s|'password'.*|'password' => '$MARIADB_PASSWORD',|g" db.inc.php
|
sed -i "s|'password'.*|'password' => '$MARIADB_PASSWORD',|g" db.inc.php
|
||||||
MARIADB_PASSWORD=
|
MARIADB_PASSWORD=
|
||||||
|
|
||||||
|
@ -298,14 +298,14 @@ function remove_movim {
|
||||||
|
|
||||||
read_config_param "MY_USERNAME"
|
read_config_param "MY_USERNAME"
|
||||||
echo "Removing $MOVIM_DOMAIN_NAME"
|
echo "Removing $MOVIM_DOMAIN_NAME"
|
||||||
nginx_dissite $MOVIM_DOMAIN_NAME
|
nginx_dissite "$MOVIM_DOMAIN_NAME"
|
||||||
remove_certs $MOVIM_DOMAIN_NAME
|
remove_certs "$MOVIM_DOMAIN_NAME"
|
||||||
|
|
||||||
if [ -d /var/www/$MOVIM_DOMAIN_NAME ]; then
|
if [ -d "/var/www/$MOVIM_DOMAIN_NAME" ]; then
|
||||||
rm -rf /var/www/$MOVIM_DOMAIN_NAME
|
rm -rf "/var/www/$MOVIM_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ -f /etc/nginx/sites-available/$MOVIM_DOMAIN_NAME ]; then
|
if [ -f "/etc/nginx/sites-available/$MOVIM_DOMAIN_NAME" ]; then
|
||||||
rm /etc/nginx/sites-available/$MOVIM_DOMAIN_NAME
|
rm "/etc/nginx/sites-available/$MOVIM_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
function_check drop_database
|
function_check drop_database
|
||||||
drop_database movim
|
drop_database movim
|
||||||
|
@ -316,15 +316,15 @@ function remove_movim {
|
||||||
fi
|
fi
|
||||||
remove_app movim
|
remove_app movim
|
||||||
remove_completion_param install_movim
|
remove_completion_param install_movim
|
||||||
sed -i '/movim/d' $COMPLETION_FILE
|
sed -i '/movim/d' "$COMPLETION_FILE"
|
||||||
remove_backup_database_local movim
|
remove_backup_database_local movim
|
||||||
|
|
||||||
function_check remove_ddns_domain
|
function_check remove_ddns_domain
|
||||||
remove_ddns_domain $MOVIM_DOMAIN_NAME
|
remove_ddns_domain "$MOVIM_DOMAIN_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_movim {
|
function install_movim {
|
||||||
if [ ! $MOVIM_DOMAIN_NAME ]; then
|
if [ ! "$MOVIM_DOMAIN_NAME" ]; then
|
||||||
echo $'No domain name was given for movim'
|
echo $'No domain name was given for movim'
|
||||||
exit 72572
|
exit 72572
|
||||||
fi
|
fi
|
||||||
|
@ -333,7 +333,7 @@ function install_movim {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
movim_hourly_script movim $MOVIM_DOMAIN_NAME
|
movim_hourly_script movim "$MOVIM_DOMAIN_NAME"
|
||||||
|
|
||||||
function_check install_mariadb
|
function_check install_mariadb
|
||||||
install_mariadb
|
install_mariadb
|
||||||
|
@ -347,221 +347,221 @@ function install_movim {
|
||||||
apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
|
apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
|
||||||
apt-get -yq install php-memcached php-intl exiftool php-imagick libfcgi0ldbl
|
apt-get -yq install php-memcached php-intl exiftool php-imagick libfcgi0ldbl
|
||||||
|
|
||||||
if [ ! -d /var/www/$MOVIM_DOMAIN_NAME ]; then
|
if [ ! -d "/var/www/$MOVIM_DOMAIN_NAME" ]; then
|
||||||
mkdir /var/www/$MOVIM_DOMAIN_NAME
|
mkdir "/var/www/$MOVIM_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ ! -d /var/www/$MOVIM_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$MOVIM_DOMAIN_NAME/htdocs" ]; then
|
||||||
|
|
||||||
if [ -d /repos/movim ]; then
|
if [ -d /repos/movim ]; then
|
||||||
mkdir /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
mkdir "/var/www/$MOVIM_DOMAIN_NAME/htdocs"
|
||||||
cp -r -p /repos/movim/. /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
cp -r -p /repos/movim/. "/var/www/$MOVIM_DOMAIN_NAME/htdocs"
|
||||||
cd /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
cd "/var/www/$MOVIM_DOMAIN_NAME/htdocs" || exit 3768568325
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
git_clone $MOVIM_REPO /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
git_clone "$MOVIM_REPO" "/var/www/$MOVIM_DOMAIN_NAME/htdocs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /var/www/$MOVIM_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$MOVIM_DOMAIN_NAME/htdocs" ]; then
|
||||||
echo $'Unable to clone movim repo'
|
echo $'Unable to clone movim repo'
|
||||||
exit 76285
|
exit 76285
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
cd "/var/www/$MOVIM_DOMAIN_NAME/htdocs" || exit 7345247242
|
||||||
git checkout $MOVIM_COMMIT -b $MOVIM_COMMIT
|
git checkout $MOVIM_COMMIT -b $MOVIM_COMMIT
|
||||||
set_completion_param "movim commit" "$MOVIM_COMMIT"
|
set_completion_param "movim commit" "$MOVIM_COMMIT"
|
||||||
|
|
||||||
# default login
|
# default login
|
||||||
if [ ! -f /var/www/$MOVIM_DOMAIN_NAME/htdocs/app/models/config/Config.php ]; then
|
if [ ! -f "/var/www/$MOVIM_DOMAIN_NAME/htdocs/app/models/config/Config.php" ]; then
|
||||||
echo $'Unable to find Config.php'
|
echo $'Unable to find Config.php'
|
||||||
exit 72352
|
exit 72352
|
||||||
fi
|
fi
|
||||||
sed -i "s|'admin'|'${MY_USERNAME}'|g" /var/www/$MOVIM_DOMAIN_NAME/htdocs/app/models/config/Config.php
|
sed -i "s|'admin'|'${MY_USERNAME}'|g" "/var/www/$MOVIM_DOMAIN_NAME/htdocs/app/models/config/Config.php"
|
||||||
sed -i "s|'password'|'${MOVIM_ADMIN_PASSWORD}'|g" /var/www/$MOVIM_DOMAIN_NAME/htdocs/app/models/config/Config.php
|
sed -i "s|'password'|'${MOVIM_ADMIN_PASSWORD}'|g" "/var/www/$MOVIM_DOMAIN_NAME/htdocs/app/models/config/Config.php"
|
||||||
|
|
||||||
# Fix typo
|
# Fix typo
|
||||||
sed -i 's|weksocket|websocket|g' app/widgets/AdminTest/admintest.js
|
sed -i 's|weksocket|websocket|g' app/widgets/AdminTest/admintest.js
|
||||||
|
|
||||||
cd /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
cd "/var/www/$MOVIM_DOMAIN_NAME/htdocs" || exit 784368245224
|
||||||
install_composer
|
install_composer
|
||||||
|
|
||||||
cd /var/www/$MOVIM_DOMAIN_NAME/htdocs/config
|
cd "/var/www/$MOVIM_DOMAIN_NAME/htdocs/config" || exit 6428764224
|
||||||
cp db.example.inc.php db.inc.php
|
cp db.example.inc.php db.inc.php
|
||||||
sed -i "s|'username'.*|'username' => 'root',|g" db.inc.php
|
sed -i "s|'username'.*|'username' => 'root',|g" db.inc.php
|
||||||
sed -i "s|'password'.*|'password' => '$MARIADB_PASSWORD',|g" db.inc.php
|
sed -i "s|'password'.*|'password' => '$MARIADB_PASSWORD',|g" db.inc.php
|
||||||
sed -i "s|'database'.*|'database' => 'movim'|g" db.inc.php
|
sed -i "s|'database'.*|'database' => 'movim'|g" db.inc.php
|
||||||
php mud.php db --set
|
php mud.php db --set
|
||||||
|
|
||||||
chmod u+rwx /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
chmod u+rwx "/var/www/$MOVIM_DOMAIN_NAME/htdocs"
|
||||||
chown -R www-data:www-data /var/www/$MOVIM_DOMAIN_NAME/htdocs
|
chown -R www-data:www-data "/var/www/$MOVIM_DOMAIN_NAME/htdocs"
|
||||||
|
|
||||||
function_check movim_create_database
|
function_check movim_create_database
|
||||||
movim_create_database
|
movim_create_database
|
||||||
|
|
||||||
function_check add_ddns_domain
|
function_check add_ddns_domain
|
||||||
add_ddns_domain $MOVIM_DOMAIN_NAME
|
add_ddns_domain "$MOVIM_DOMAIN_NAME"
|
||||||
|
|
||||||
MOVIM_ONION_HOSTNAME=$(add_onion_service movim 80 ${MOVIM_ONION_PORT})
|
MOVIM_ONION_HOSTNAME=$(add_onion_service movim 80 ${MOVIM_ONION_PORT})
|
||||||
|
|
||||||
echo '[Unit]' > /etc/systemd/system/movim.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=Movim daemon' >> /etc/systemd/system/movim.service
|
echo 'Description=Movim daemon';
|
||||||
echo 'After=network.target nginx.target' >> /etc/systemd/system/movim.service
|
echo 'After=network.target nginx.target';
|
||||||
echo '' >> /etc/systemd/system/movim.service
|
echo '';
|
||||||
echo '[Service]' >> /etc/systemd/system/movim.service
|
echo '[Service]';
|
||||||
echo 'Type=simple' >> /etc/systemd/system/movim.service
|
echo 'Type=simple';
|
||||||
echo 'User=www-data' >> /etc/systemd/system/movim.service
|
echo 'User=www-data';
|
||||||
echo "WorkingDirectory=/var/www/$MOVIM_DOMAIN_NAME/htdocs" >> /etc/systemd/system/movim.service
|
echo "WorkingDirectory=/var/www/$MOVIM_DOMAIN_NAME/htdocs"; } > /etc/systemd/system/movim.service
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ $ONION_ONLY == 'no' ]]; then
|
||||||
echo "ExecStart=/usr/bin/php /var/www/$MOVIM_DOMAIN_NAME/htdocs/daemon.php start --url=https://$MOVIM_DOMAIN_NAME --port=$MOVIM_DAEMON_PORT" >> /etc/systemd/system/movim.service
|
echo "ExecStart=/usr/bin/php /var/www/$MOVIM_DOMAIN_NAME/htdocs/daemon.php start --url=https://$MOVIM_DOMAIN_NAME --port=$MOVIM_DAEMON_PORT" >> /etc/systemd/system/movim.service
|
||||||
else
|
else
|
||||||
echo "ExecStart=/usr/bin/php /var/www/$MOVIM_DOMAIN_NAME/htdocs/daemon.php start --url=http://$MOVIM_ONION_HOSTNAME --port=$MOVIM_DAEMON_PORT" >> /etc/systemd/system/movim.service
|
echo "ExecStart=/usr/bin/php /var/www/$MOVIM_DOMAIN_NAME/htdocs/daemon.php start --url=http://$MOVIM_ONION_HOSTNAME --port=$MOVIM_DAEMON_PORT" >> /etc/systemd/system/movim.service
|
||||||
fi
|
fi
|
||||||
echo 'StandardOutput=syslog' >> /etc/systemd/system/movim.service
|
{ echo 'StandardOutput=syslog';
|
||||||
echo 'SyslogIdentifier=movim' >> /etc/systemd/system/movim.service
|
echo 'SyslogIdentifier=movim';
|
||||||
echo 'PIDFile=/run/movim.pid' >> /etc/systemd/system/movim.service
|
echo 'PIDFile=/run/movim.pid';
|
||||||
echo 'Restart=on-failure' >> /etc/systemd/system/movim.service
|
echo 'Restart=on-failure';
|
||||||
echo 'RestartSec=10' >> /etc/systemd/system/movim.service
|
echo 'RestartSec=10';
|
||||||
echo '' >> /etc/systemd/system/movim.service
|
echo '';
|
||||||
echo '[Install]' >> /etc/systemd/system/movim.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/movim.service
|
echo 'WantedBy=multi-user.target'; } >> /etc/systemd/system/movim.service
|
||||||
systemctl enable movim
|
systemctl enable movim
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
movim_nginx_site=/etc/nginx/sites-available/$MOVIM_DOMAIN_NAME
|
movim_nginx_site=/etc/nginx/sites-available/$MOVIM_DOMAIN_NAME
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $MOVIM_DOMAIN_NAME "index index.php"
|
nginx_http_redirect "$MOVIM_DOMAIN_NAME" "index index.php"
|
||||||
echo 'server {' >> $movim_nginx_site
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> $movim_nginx_site
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> $movim_nginx_site
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo " server_name $MOVIM_DOMAIN_NAME;" >> $movim_nginx_site
|
echo " server_name $MOVIM_DOMAIN_NAME;";
|
||||||
echo '' >> $movim_nginx_site
|
echo ''; } >> "$movim_nginx_site"
|
||||||
function_check nginx_compress
|
function_check nginx_compress
|
||||||
nginx_compress $MOVIM_DOMAIN_NAME
|
nginx_compress "$MOVIM_DOMAIN_NAME"
|
||||||
echo '' >> $movim_nginx_site
|
echo '' >> "$movim_nginx_site"
|
||||||
echo ' # Security' >> $movim_nginx_site
|
echo ' # Security' >> "$movim_nginx_site"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $MOVIM_DOMAIN_NAME
|
nginx_ssl "$MOVIM_DOMAIN_NAME"
|
||||||
|
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $MOVIM_DOMAIN_NAME
|
nginx_disable_sniffing "$MOVIM_DOMAIN_NAME"
|
||||||
|
|
||||||
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $movim_nginx_site
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Logs' >> $movim_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $movim_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $movim_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $movim_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$MOVIM_DOMAIN_NAME/htdocs;" >> $movim_nginx_site
|
echo " root /var/www/$MOVIM_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Index' >> $movim_nginx_site
|
echo ' # Index';
|
||||||
echo ' index index.php;' >> $movim_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # PHP' >> $movim_nginx_site
|
echo ' # PHP';
|
||||||
echo ' location ~ \.php {' >> $movim_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $movim_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $movim_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $movim_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $movim_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $movim_nginx_site
|
echo ' location / {'; } >> "$movim_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $MOVIM_DOMAIN_NAME '15m'
|
nginx_limits "$MOVIM_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @movim;' >> $movim_nginx_site
|
{ echo " try_files \$uri \$uri/ @movim;";
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' location /ws/ {' >> $movim_nginx_site
|
echo ' location /ws/ {';
|
||||||
echo " proxy_pass http://localhost:${MOVIM_DAEMON_PORT}/;" >> $movim_nginx_site
|
echo " proxy_pass http://localhost:${MOVIM_DAEMON_PORT}/;";
|
||||||
echo ' proxy_http_version 1.1;' >> $movim_nginx_site
|
echo ' proxy_http_version 1.1;';
|
||||||
echo ' proxy_set_header Upgrade $http_upgrade;' >> $movim_nginx_site
|
echo " proxy_set_header Upgrade \$http_upgrade;";
|
||||||
echo ' proxy_set_header Connection "Upgrade";' >> $movim_nginx_site
|
echo ' proxy_set_header Connection "Upgrade";';
|
||||||
echo ' proxy_set_header Host $host;' >> $movim_nginx_site
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $movim_nginx_site
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $movim_nginx_site
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_set_header X-Forwarded-Proto https;' >> $movim_nginx_site
|
echo ' proxy_set_header X-Forwarded-Proto https;';
|
||||||
echo ' proxy_redirect off;' >> $movim_nginx_site
|
echo ' proxy_redirect off;';
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Fancy URLs' >> $movim_nginx_site
|
echo ' # Fancy URLs';
|
||||||
echo ' location @movim {' >> $movim_nginx_site
|
echo ' location @movim {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $movim_nginx_site
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $movim_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $movim_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $movim_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo '}' >> $movim_nginx_site
|
echo '}'; } >> "$movim_nginx_site"
|
||||||
else
|
else
|
||||||
echo -n '' > $movim_nginx_site
|
echo -n '' > "$movim_nginx_site"
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> $movim_nginx_site
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:$MOVIM_ONION_PORT default_server;" >> $movim_nginx_site
|
echo " listen 127.0.0.1:$MOVIM_ONION_PORT default_server;";
|
||||||
echo " server_name $MOVIM_DOMAIN_NAME;" >> $movim_nginx_site
|
echo " server_name $MOVIM_DOMAIN_NAME;";
|
||||||
echo '' >> $movim_nginx_site
|
echo ''; } >> "$movim_nginx_site"
|
||||||
function_check nginx_compress
|
function_check nginx_compress
|
||||||
nginx_compress $MOVIM_DOMAIN_NAME
|
nginx_compress "$MOVIM_DOMAIN_NAME"
|
||||||
echo '' >> $movim_nginx_site
|
echo '' >> "$movim_nginx_site"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $MOVIM_DOMAIN_NAME
|
nginx_disable_sniffing "$MOVIM_DOMAIN_NAME"
|
||||||
echo '' >> $movim_nginx_site
|
{ echo '';
|
||||||
echo ' # Logs' >> $movim_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $movim_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $movim_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $movim_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$MOVIM_DOMAIN_NAME/htdocs;" >> $movim_nginx_site
|
echo " root /var/www/$MOVIM_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Index' >> $movim_nginx_site
|
echo ' # Index';
|
||||||
echo ' index index.php;' >> $movim_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # PHP' >> $movim_nginx_site
|
echo ' # PHP';
|
||||||
echo ' location ~ \.php {' >> $movim_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $movim_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $movim_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $movim_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $movim_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $movim_nginx_site
|
echo ' location / {'; } >> "$movim_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $MOVIM_DOMAIN_NAME '15m'
|
nginx_limits "$MOVIM_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @movim;' >> $movim_nginx_site
|
{ echo " try_files \$uri \$uri/ @movim;";
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' location /ws/ {' >> $movim_nginx_site
|
echo ' location /ws/ {';
|
||||||
echo " proxy_pass http://localhost:${MOVIM_DAEMON_PORT}/;" >> $movim_nginx_site
|
echo " proxy_pass http://localhost:${MOVIM_DAEMON_PORT}/;";
|
||||||
echo ' proxy_http_version 1.1;' >> $movim_nginx_site
|
echo ' proxy_http_version 1.1;';
|
||||||
echo ' proxy_set_header Upgrade $http_upgrade;' >> $movim_nginx_site
|
echo " proxy_set_header Upgrade \$http_upgrade;";
|
||||||
echo ' proxy_set_header Connection "Upgrade";' >> $movim_nginx_site
|
echo ' proxy_set_header Connection "Upgrade";';
|
||||||
echo ' proxy_set_header Host $host;' >> $movim_nginx_site
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $movim_nginx_site
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $movim_nginx_site
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_set_header X-Forwarded-Proto https;' >> $movim_nginx_site
|
echo ' proxy_set_header X-Forwarded-Proto https;';
|
||||||
echo ' proxy_redirect off;' >> $movim_nginx_site
|
echo ' proxy_redirect off;';
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Fancy URLs' >> $movim_nginx_site
|
echo ' # Fancy URLs';
|
||||||
echo ' location @movim {' >> $movim_nginx_site
|
echo ' location @movim {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $movim_nginx_site
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $movim_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $movim_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $movim_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $movim_nginx_site
|
echo ' }';
|
||||||
echo '' >> $movim_nginx_site
|
echo '';
|
||||||
echo '}' >> $movim_nginx_site
|
echo '}'; } >> "$movim_nginx_site"
|
||||||
|
|
||||||
function_check configure_php
|
function_check configure_php
|
||||||
configure_php
|
configure_php
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate $MOVIM_DOMAIN_NAME 'yes'
|
create_site_certificate "$MOVIM_DOMAIN_NAME" 'yes'
|
||||||
|
|
||||||
# Ensure that the database gets backed up locally, if remote
|
# Ensure that the database gets backed up locally, if remote
|
||||||
# backups are not being used
|
# backups are not being used
|
||||||
|
@ -572,9 +572,9 @@ function install_movim {
|
||||||
backup_database_local movim
|
backup_database_local movim
|
||||||
|
|
||||||
function_check nginx_ensite
|
function_check nginx_ensite
|
||||||
nginx_ensite $MOVIM_DOMAIN_NAME
|
nginx_ensite "$MOVIM_DOMAIN_NAME"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a movim -p "$MOVIM_ADMIN_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a movim -p "$MOVIM_ADMIN_PASSWORD"
|
||||||
|
|
||||||
set_completion_param "movim domain" "$MOVIM_DOMAIN_NAME"
|
set_completion_param "movim domain" "$MOVIM_DOMAIN_NAME"
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ function upgrade_mumble {
|
||||||
usermod -a -G ssl-cert mumble-server
|
usermod -a -G ssl-cert mumble-server
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f /etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem ]; then
|
if [ ! -f "/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem" ]; then
|
||||||
if ! grep -q "mumble.pem" /etc/mumble-server.ini; then
|
if ! grep -q "mumble.pem" /etc/mumble-server.ini; then
|
||||||
sed -i 's|sslCert=.*|sslCert=/var/lib/mumble-server/mumble.pem|g' /etc/mumble-server.ini
|
sed -i 's|sslCert=.*|sslCert=/var/lib/mumble-server/mumble.pem|g' /etc/mumble-server.ini
|
||||||
sed -i 's|sslKey=.*|sslKey=/var/lib/mumble-server/mumble.key|g' /etc/mumble-server.ini
|
sed -i 's|sslKey=.*|sslKey=/var/lib/mumble-server/mumble.key|g' /etc/mumble-server.ini
|
||||||
|
@ -117,17 +117,18 @@ function backup_local_mumble {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_local_mumble {
|
function restore_local_mumble {
|
||||||
if [ -d $USB_MOUNT/backup/mumble ]; then
|
if [ -d "$USB_MOUNT/backup/mumble" ]; then
|
||||||
echo $"Restoring mumble settings"
|
echo $"Restoring mumble settings"
|
||||||
temp_restore_dir=/root/tempmumble
|
temp_restore_dir=/root/tempmumble
|
||||||
function_check restore_directory_from_usb
|
function_check restore_directory_from_usb
|
||||||
restore_directory_from_usb $temp_restore_dir voip
|
restore_directory_from_usb $temp_restore_dir voip
|
||||||
restore_directory_from_usb $temp_restore_dir mumble
|
restore_directory_from_usb $temp_restore_dir mumble
|
||||||
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
|
if [ -d "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup" ]; then
|
||||||
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
cp -f "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini" /etc/
|
||||||
else
|
else
|
||||||
cp -f $temp_restore_dir/mumble-server.ini /etc/
|
cp -f $temp_restore_dir/mumble-server.ini /etc/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
function_check set_user_permissions
|
function_check set_user_permissions
|
||||||
|
@ -136,11 +137,12 @@ function restore_local_mumble {
|
||||||
backup_unmount_drive
|
backup_unmount_drive
|
||||||
exit 3679
|
exit 3679
|
||||||
fi
|
fi
|
||||||
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
|
if [ -d "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup" ]; then
|
||||||
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
cp -f "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite" /var/lib/mumble-server/
|
||||||
else
|
else
|
||||||
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
|
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
function_check set_user_permissions
|
function_check set_user_permissions
|
||||||
|
@ -171,29 +173,27 @@ function backup_remote_mumble {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_remote_mumble {
|
function restore_remote_mumble {
|
||||||
if [ -d $SERVER_DIRECTORY/backup/mumble ]; then
|
if [ -d "$SERVER_DIRECTORY/backup/mumble" ]; then
|
||||||
echo $"Restoring Mumble settings"
|
echo $"Restoring Mumble settings"
|
||||||
temp_restore_dir=/root/tempmumble
|
temp_restore_dir=/root/tempmumble
|
||||||
function_check restore_directory_from_friend
|
function_check restore_directory_from_friend
|
||||||
restore_directory_from_friend $temp_restore_dir mumble
|
restore_directory_from_friend $temp_restore_dir mumble
|
||||||
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
|
if [ -d "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup" ]; then
|
||||||
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
cp -f "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini" /etc/
|
||||||
else
|
else
|
||||||
cp -f $temp_restore_dir/mumble-server.ini /etc/
|
cp -f $temp_restore_dir/mumble-server.ini /etc/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
exit 7823
|
exit 7823
|
||||||
fi
|
fi
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ -d "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup" ]; then
|
||||||
rm -rf $temp_restore_dir
|
cp -f "$temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite" /var/lib/mumble-server/
|
||||||
exit 7823
|
|
||||||
fi
|
|
||||||
if [ $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
|
|
||||||
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
|
||||||
else
|
else
|
||||||
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
|
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
exit 276
|
exit 276
|
||||||
|
@ -221,7 +221,7 @@ function remove_mumble {
|
||||||
fi
|
fi
|
||||||
function_check remove_onion_service
|
function_check remove_onion_service
|
||||||
remove_onion_service mumble ${MUMBLE_PORT}
|
remove_onion_service mumble ${MUMBLE_PORT}
|
||||||
sed -i '/mumble/d' $COMPLETION_FILE
|
sed -i '/mumble/d' "$COMPLETION_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_firewall_for_mumble {
|
function configure_firewall_for_mumble {
|
||||||
|
@ -238,34 +238,34 @@ function configure_firewall_for_mumble {
|
||||||
function install_mumble {
|
function install_mumble {
|
||||||
apt-get -yq install mumble-server
|
apt-get -yq install mumble-server
|
||||||
|
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
MUMBLE_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
MUMBLE_SERVER_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
if [ ! $MUMBLE_SERVER_PASSWORD ]; then
|
if [ ! "$MUMBLE_SERVER_PASSWORD" ]; then
|
||||||
MUMBLE_SERVER_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
MUMBLE_SERVER_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
if [ ${#MUMBLE_SERVER_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
|
if [ ${#MUMBLE_SERVER_PASSWORD} -lt "$MINIMUM_PASSWORD_LENGTH" ]; then
|
||||||
MUMBLE_SERVER_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
MUMBLE_SERVER_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${ONION_ONLY} == 'no' ]]; then
|
if [[ ${ONION_ONLY} == 'no' ]]; then
|
||||||
if [ ! -d /var/www/${DEFAULT_DOMAIN_NAME}/htdocs ]; then
|
if [ ! -d "/var/www/${DEFAULT_DOMAIN_NAME}/htdocs" ]; then
|
||||||
mkdir /var/www/${DEFAULT_DOMAIN_NAME}/htdocs
|
mkdir "/var/www/${DEFAULT_DOMAIN_NAME}/htdocs"
|
||||||
fi
|
fi
|
||||||
if [ ! -f /etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem ]; then
|
if [ ! -f "/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem" ]; then
|
||||||
if [ -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt ]; then
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt" ]; then
|
||||||
rm /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt
|
rm "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt"
|
||||||
fi
|
fi
|
||||||
if [ -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam ]; then
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam" ]; then
|
||||||
rm /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam
|
rm "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam"
|
||||||
fi
|
fi
|
||||||
echo $'Obtaining certificate for the main domain'
|
echo $'Obtaining certificate for the main domain'
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate ${DEFAULT_DOMAIN_NAME} 'yes'
|
create_site_certificate "${DEFAULT_DOMAIN_NAME}" 'yes'
|
||||||
chmod 755 /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam
|
chmod 755 "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam"
|
||||||
|
|
||||||
if [ -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt ]; then
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt" ]; then
|
||||||
echo $'Incorrect certificate generated'
|
echo $'Incorrect certificate generated'
|
||||||
exit 78352
|
exit 78352
|
||||||
fi
|
fi
|
||||||
|
@ -276,9 +276,9 @@ function install_mumble {
|
||||||
|
|
||||||
|
|
||||||
# Make an ssl cert for the server
|
# Make an ssl cert for the server
|
||||||
if [ ! -f /etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem ]; then
|
if [ ! -f "/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem" ]; then
|
||||||
if [ ! -f /etc/ssl/certs/mumble.dhparam ]; then
|
if [ ! -f /etc/ssl/certs/mumble.dhparam ]; then
|
||||||
${PROJECT_NAME}-addcert -h mumble --dhkey $DH_KEYLENGTH
|
"${PROJECT_NAME}-addcert" -h mumble --dhkey "$DH_KEYLENGTH"
|
||||||
function_check check_certificates
|
function_check check_certificates
|
||||||
check_certificates mumble
|
check_certificates mumble
|
||||||
fi
|
fi
|
||||||
|
@ -318,7 +318,7 @@ function install_mumble {
|
||||||
echo 'allowping=False' >> /etc/mumble-server.ini
|
echo 'allowping=False' >> /etc/mumble-server.ini
|
||||||
fi
|
fi
|
||||||
sed -i 's|allowping=.*|allowping=False|g' /etc/mumble-server.ini
|
sed -i 's|allowping=.*|allowping=False|g' /etc/mumble-server.ini
|
||||||
if [ ! -f /etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem ]; then
|
if [ ! -f "/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem" ]; then
|
||||||
sed -i 's|#sslCert=.*|sslCert=/var/lib/mumble-server/mumble.pem|g' /etc/mumble-server.ini
|
sed -i 's|#sslCert=.*|sslCert=/var/lib/mumble-server/mumble.pem|g' /etc/mumble-server.ini
|
||||||
sed -i 's|#sslKey=.*|sslKey=/var/lib/mumble-server/mumble.key|g' /etc/mumble-server.ini
|
sed -i 's|#sslKey=.*|sslKey=/var/lib/mumble-server/mumble.key|g' /etc/mumble-server.ini
|
||||||
else
|
else
|
||||||
|
@ -335,7 +335,8 @@ function install_mumble {
|
||||||
sed -i 's|allowhtml=.*|allowhtml=False|g' /etc/mumble-server.ini
|
sed -i 's|allowhtml=.*|allowhtml=False|g' /etc/mumble-server.ini
|
||||||
sed -i "s|port=.*|port=${MUMBLE_PORT}|g" /etc/mumble-server.ini
|
sed -i "s|port=.*|port=${MUMBLE_PORT}|g" /etc/mumble-server.ini
|
||||||
|
|
||||||
MUMBLE_ONION_HOSTNAME=$(add_onion_service mumble ${MUMBLE_PORT} ${MUMBLE_PORT})
|
#MUMBLE_ONION_HOSTNAME=$(add_onion_service mumble ${MUMBLE_PORT} ${MUMBLE_PORT})
|
||||||
|
add_onion_service mumble ${MUMBLE_PORT} ${MUMBLE_PORT}
|
||||||
|
|
||||||
# turn off logs by default
|
# turn off logs by default
|
||||||
sed -i 's|logfile=.*|logfile=/dev/null|g' /etc/mumble-server.ini
|
sed -i 's|logfile=.*|logfile=/dev/null|g' /etc/mumble-server.ini
|
||||||
|
|
|
@ -60,14 +60,14 @@ function logging_off_nextcloud {
|
||||||
function remove_user_nextcloud {
|
function remove_user_nextcloud {
|
||||||
remove_username="$1"
|
remove_username="$1"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $remove_username --rmapp nextcloud
|
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp nextcloud
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_user_nextcloud {
|
function add_user_nextcloud {
|
||||||
new_username="$1"
|
new_username="$1"
|
||||||
new_user_password="$2"
|
new_user_password="$2"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $new_username -a nextcloud -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$new_username" -a nextcloud -p "$new_user_password"
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +76,12 @@ function change_password_nextcloud {
|
||||||
|
|
||||||
export OC_PASS="$2"
|
export OC_PASS="$2"
|
||||||
su -s /bin/sh www-data -c "php occ user:resetpassword --password-from-env $curr_username"
|
su -s /bin/sh www-data -c "php occ user:resetpassword --password-from-env $curr_username"
|
||||||
${PROJECT_NAME}-pass -u $curr_username -a nextcloud -p "$OC_PASS"
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a nextcloud -p "$OC_PASS"
|
||||||
export OC_PASS=""
|
export OC_PASS=""
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_interactive_nextcloud {
|
function install_interactive_nextcloud {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -91,42 +91,40 @@ function install_interactive_nextcloud {
|
||||||
NEXTCLOUD_DETAILS_COMPLETE=
|
NEXTCLOUD_DETAILS_COMPLETE=
|
||||||
while [ ! $NEXTCLOUD_DETAILS_COMPLETE ]
|
while [ ! $NEXTCLOUD_DETAILS_COMPLETE ]
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"NextCloud Configuration" \
|
--title $"NextCloud Configuration" \
|
||||||
--form $"\nPlease enter your NextCloud details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 3 \
|
--form $"\\nPlease enter your NextCloud details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 3 \
|
||||||
$"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
$"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
||||||
$"Code:" 2 1 "$(grep 'NEXTCLOUD_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 40 255 \
|
$"Code:" 2 1 "$(grep 'NEXTCLOUD_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 40 255 \
|
||||||
2> $data
|
2> "$data"
|
||||||
else
|
else
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"NextCloud Configuration" \
|
--title $"NextCloud Configuration" \
|
||||||
--form $"\nPlease enter your NextCloud details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 2 \
|
--form $"\\nPlease enter your NextCloud details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
$"Domain:" 1 1 "$(grep 'NEXTCLOUD_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
||||||
2> $data
|
2> "$data"
|
||||||
fi
|
fi
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) rm -f "$data"
|
||||||
255) exit 1;;
|
exit 1;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
NEXTCLOUD_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
NEXTCLOUD_DOMAIN_NAME=$(sed -n 1p < "$data")
|
||||||
if [ ${#img_url} -gt 1 ]; then
|
if [ "$NEXTCLOUD_DOMAIN_NAME" ]; then
|
||||||
NEXTCLOUD_BACKGROUND_IMAGE_URL=$img_url
|
|
||||||
fi
|
|
||||||
if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
|
||||||
TEST_DOMAIN_NAME=$NEXTCLOUD_DOMAIN_NAME
|
TEST_DOMAIN_NAME=$NEXTCLOUD_DOMAIN_NAME
|
||||||
validate_domain_name
|
validate_domain_name
|
||||||
if [[ $TEST_DOMAIN_NAME != $NEXTCLOUD_DOMAIN_NAME ]]; then
|
if [[ "$TEST_DOMAIN_NAME" != "$NEXTCLOUD_DOMAIN_NAME" ]]; then
|
||||||
NEXTCLOUD_DOMAIN_NAME=
|
NEXTCLOUD_DOMAIN_NAME=
|
||||||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||||||
else
|
else
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
NEXTCLOUD_CODE=$(cat $data | sed -n 2p)
|
NEXTCLOUD_CODE=$(sed -n 2p < "$data")
|
||||||
validate_freedns_code "$NEXTCLOUD_CODE"
|
validate_freedns_code "$NEXTCLOUD_CODE"
|
||||||
if [ ! $VALID_CODE ]; then
|
if [ ! "$VALID_CODE" ]; then
|
||||||
NEXTCLOUD_DOMAIN_NAME=
|
NEXTCLOUD_DOMAIN_NAME=
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -135,11 +133,12 @@ function install_interactive_nextcloud {
|
||||||
if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
||||||
NEXTCLOUD_DETAILS_COMPLETE="yes"
|
NEXTCLOUD_DETAILS_COMPLETE="yes"
|
||||||
fi
|
fi
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
|
|
||||||
# remove any invalid characters
|
# remove any invalid characters
|
||||||
if [ ${#NEXTCLOUD_TITLE} -gt 0 ]; then
|
if [ ${#NEXTCLOUD_TITLE} -gt 0 ]; then
|
||||||
new_title=$(echo "$NEXTCLOUD_TITLE" | sed "s|'||g")
|
new_title=${"$NEXTCLOUD_TITLE"//\'//}
|
||||||
NEXTCLOUD_TITLE="$new_title"
|
NEXTCLOUD_TITLE="$new_title"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -156,23 +155,23 @@ function change_password_nextcloud {
|
||||||
|
|
||||||
read_config_param ${NEXTCLOUD_DOMAIN_NAME}
|
read_config_param ${NEXTCLOUD_DOMAIN_NAME}
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u "$curr_username" -a nextcloud -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a nextcloud -p "$new_user_password"
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextcloud_create_database {
|
function nextcloud_create_database {
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
NEXTCLOUD_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
NEXTCLOUD_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
if [ ! $NEXTCLOUD_ADMIN_PASSWORD ]; then
|
if [ ! "$NEXTCLOUD_ADMIN_PASSWORD" ]; then
|
||||||
NEXTCLOUD_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
NEXTCLOUD_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! $NEXTCLOUD_ADMIN_PASSWORD ]; then
|
if [ ! "$NEXTCLOUD_ADMIN_PASSWORD" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check create_database
|
function_check create_database
|
||||||
create_database nextcloud "$NEXTCLOUD_ADMIN_PASSWORD" $MY_USERNAME
|
create_database nextcloud "$NEXTCLOUD_ADMIN_PASSWORD" "$MY_USERNAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function reconfigure_nextcloud {
|
function reconfigure_nextcloud {
|
||||||
|
@ -186,7 +185,7 @@ function configure_interactive_nextcloud {
|
||||||
function upgrade_nextcloud_base {
|
function upgrade_nextcloud_base {
|
||||||
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
||||||
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/data
|
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/data
|
||||||
cd /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
cd "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" || exit 232547985
|
||||||
sudo -u www-data ./occ maintenance:repair
|
sudo -u www-data ./occ maintenance:repair
|
||||||
sudo -u www-data ./occ files:cleanup
|
sudo -u www-data ./occ files:cleanup
|
||||||
sudo -u www-data ./occ files:scan --all
|
sudo -u www-data ./occ files:scan --all
|
||||||
|
@ -200,13 +199,13 @@ function upgrade_nextcloud {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
||||||
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update to the next commit
|
# update to the next commit
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs "nextcloud commit" "$NEXTCLOUD_COMMIT" $NEXTCLOUD_REPO
|
set_repo_commit "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" "nextcloud commit" "$NEXTCLOUD_COMMIT" "$NEXTCLOUD_REPO"
|
||||||
|
|
||||||
upgrade_nextcloud_base
|
upgrade_nextcloud_base
|
||||||
sudo -u www-data ./occ upgrade
|
sudo -u www-data ./occ upgrade
|
||||||
|
@ -215,22 +214,22 @@ function upgrade_nextcloud {
|
||||||
|
|
||||||
function backup_local_nextcloud {
|
function backup_local_nextcloud {
|
||||||
NEXTCLOUD_DOMAIN_NAME='nextcloud'
|
NEXTCLOUD_DOMAIN_NAME='nextcloud'
|
||||||
if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
||||||
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
||||||
if [ -d $source_directory ]; then
|
if [ -d "$source_directory" ]; then
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${NEXTCLOUD_DOMAIN_NAME}
|
suspend_site "${NEXTCLOUD_DOMAIN_NAME}"
|
||||||
|
|
||||||
dest_directory=nextcloudfiles
|
dest_directory=nextcloudfiles
|
||||||
function_check backup_directory_to_usb
|
function_check backup_directory_to_usb
|
||||||
backup_directory_to_usb $source_directory $dest_directory
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
|
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
|
||||||
dest_directory=nextcloudconfig
|
dest_directory=nextcloudconfig
|
||||||
backup_directory_to_usb $source_directory $dest_directory
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
function_check backup_database_to_usb
|
function_check backup_database_to_usb
|
||||||
backup_database_to_usb nextcloud
|
backup_database_to_usb nextcloud
|
||||||
|
@ -241,26 +240,26 @@ function backup_local_nextcloud {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_local_nextcloud {
|
function restore_local_nextcloud {
|
||||||
if ! grep -q "nextcloud domain" $COMPLETION_FILE; then
|
if ! grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
||||||
if [ $NEXTCLOUD_DOMAIN_NAME ]; then
|
if [ "$NEXTCLOUD_DOMAIN_NAME" ]; then
|
||||||
|
|
||||||
temp_restore_dir=/root/tempnextcloud
|
temp_restore_dir=/root/tempnextcloud
|
||||||
function_check nextcloud_create_database
|
function_check nextcloud_create_database
|
||||||
nextcloud_create_database
|
nextcloud_create_database
|
||||||
restore_database nextcloud ${NEXTCLOUD_DOMAIN_NAME}
|
restore_database nextcloud "${NEXTCLOUD_DOMAIN_NAME}"
|
||||||
|
|
||||||
temp_restore_dir=/root/tempnextcloudfiles
|
temp_restore_dir=/root/tempnextcloudfiles
|
||||||
restore_directory_from_usb $temp_restore_dir nextcloudfiles
|
restore_directory_from_usb $temp_restore_dir nextcloudfiles
|
||||||
|
|
||||||
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" ]; then
|
||||||
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
set_user_permissions
|
set_user_permissions
|
||||||
backup_unmount_drive
|
backup_unmount_drive
|
||||||
|
@ -271,12 +270,13 @@ function restore_local_nextcloud {
|
||||||
temp_restore_dir=/root/tempnextcloudconfig
|
temp_restore_dir=/root/tempnextcloudconfig
|
||||||
restore_directory_from_usb $temp_restore_dir nextcloudconfig
|
restore_directory_from_usb $temp_restore_dir nextcloudconfig
|
||||||
|
|
||||||
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" ]; then
|
||||||
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
set_user_permissions
|
set_user_permissions
|
||||||
backup_unmount_drive
|
backup_unmount_drive
|
||||||
|
@ -284,9 +284,9 @@ function restore_local_nextcloud {
|
||||||
fi
|
fi
|
||||||
rm -rf ${temp_restore_dir}
|
rm -rf ${temp_restore_dir}
|
||||||
|
|
||||||
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
||||||
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/data"
|
||||||
cd $nextcloud_dir
|
cd "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs" || exit 14893545875
|
||||||
sudo -u www-data ./occ maintenance:repair
|
sudo -u www-data ./occ maintenance:repair
|
||||||
sudo -u www-data ./occ files:cleanup
|
sudo -u www-data ./occ files:cleanup
|
||||||
sudo -u www-data ./occ files:scan --all
|
sudo -u www-data ./occ files:scan --all
|
||||||
|
@ -294,21 +294,21 @@ function restore_local_nextcloud {
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_remote_nextcloud {
|
function backup_remote_nextcloud {
|
||||||
if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
||||||
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
||||||
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
||||||
if [ -d $temp_backup_dir ]; then
|
if [ -d "$temp_backup_dir" ]; then
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${NEXTCLOUD_DOMAIN_NAME}
|
suspend_site "${NEXTCLOUD_DOMAIN_NAME}"
|
||||||
|
|
||||||
function_check backup_database_to_friend
|
function_check backup_database_to_friend
|
||||||
backup_database_to_friend nextcloud
|
backup_database_to_friend nextcloud
|
||||||
|
|
||||||
function_check backup_directory_to_friend
|
function_check backup_directory_to_friend
|
||||||
backup_directory_to_friend $temp_backup_dir nextclouddata
|
backup_directory_to_friend "$temp_backup_dir" nextclouddata
|
||||||
|
|
||||||
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
|
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
|
||||||
backup_directory_to_friend $temp_backup_dir nextcloudconfig
|
backup_directory_to_friend "$temp_backup_dir" nextcloudconfig
|
||||||
|
|
||||||
function_check restart_site
|
function_check restart_site
|
||||||
restart_site
|
restart_site
|
||||||
|
@ -319,7 +319,7 @@ function backup_remote_nextcloud {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_remote_nextcloud {
|
function restore_remote_nextcloud {
|
||||||
if grep -q "nextcloud domain" $COMPLETION_FILE; then
|
if grep -q "nextcloud domain" "$COMPLETION_FILE"; then
|
||||||
echo $"Restoring nextcloud"
|
echo $"Restoring nextcloud"
|
||||||
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ function restore_remote_nextcloud {
|
||||||
nextcloud_create_database
|
nextcloud_create_database
|
||||||
|
|
||||||
function_check restore_database_from_friend
|
function_check restore_database_from_friend
|
||||||
restore_database_from_friend nextcloud ${NEXTCLOUD_DOMAIN_NAME}
|
restore_database_from_friend nextcloud "${NEXTCLOUD_DOMAIN_NAME}"
|
||||||
if [ -d /root/tempnextcloud ]; then
|
if [ -d /root/tempnextcloud ]; then
|
||||||
rm -rf /root/tempnextcloud
|
rm -rf /root/tempnextcloud
|
||||||
fi
|
fi
|
||||||
|
@ -335,12 +335,12 @@ function restore_remote_nextcloud {
|
||||||
temp_restore_dir=/root/tempnextcloudfiles
|
temp_restore_dir=/root/tempnextcloudfiles
|
||||||
restore_directory_from_friend $temp_restore_dir nextcloudfiles
|
restore_directory_from_friend $temp_restore_dir nextcloudfiles
|
||||||
|
|
||||||
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" ]; then
|
||||||
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 768254
|
exit 768254
|
||||||
fi
|
fi
|
||||||
|
@ -349,20 +349,21 @@ function restore_remote_nextcloud {
|
||||||
temp_restore_dir=/root/tempnextcloudconfig
|
temp_restore_dir=/root/tempnextcloudconfig
|
||||||
restore_directory_from_friend $temp_restore_dir nextcloudconfig
|
restore_directory_from_friend $temp_restore_dir nextcloudconfig
|
||||||
|
|
||||||
if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
|
if [ -d "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" ]; then
|
||||||
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
cp -r "$temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
|
cp -r $temp_restore_dir/* "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 573427
|
exit 573427
|
||||||
fi
|
fi
|
||||||
rm -rf ${temp_restore_dir}
|
rm -rf ${temp_restore_dir}
|
||||||
|
|
||||||
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
||||||
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/data"
|
||||||
cd /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
cd "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs" || exit 2642846824
|
||||||
sudo -u www-data ./occ maintenance:repair
|
sudo -u www-data ./occ maintenance:repair
|
||||||
sudo -u www-data ./occ files:cleanup
|
sudo -u www-data ./occ files:cleanup
|
||||||
sudo -u www-data ./occ files:scan --all
|
sudo -u www-data ./occ files:scan --all
|
||||||
|
@ -381,13 +382,13 @@ function remove_nextcloud {
|
||||||
read_config_param "NEXTCLOUD_DOMAIN_NAME"
|
read_config_param "NEXTCLOUD_DOMAIN_NAME"
|
||||||
read_config_param "MY_USERNAME"
|
read_config_param "MY_USERNAME"
|
||||||
echo "Removing $NEXTCLOUD_DOMAIN_NAME"
|
echo "Removing $NEXTCLOUD_DOMAIN_NAME"
|
||||||
nginx_dissite $NEXTCLOUD_DOMAIN_NAME
|
nginx_dissite "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
remove_certs $NEXTCLOUD_DOMAIN_NAME
|
remove_certs "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
if [ -d /var/www/$NEXTCLOUD_DOMAIN_NAME ]; then
|
if [ -d "/var/www/$NEXTCLOUD_DOMAIN_NAME" ]; then
|
||||||
rm -rf /var/www/$NEXTCLOUD_DOMAIN_NAME
|
rm -rf "/var/www/$NEXTCLOUD_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ -f /etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME ]; then
|
if [ -f "/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME" ]; then
|
||||||
rm /etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME
|
rm "/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
function_check drop_database
|
function_check drop_database
|
||||||
drop_database nextcloud
|
drop_database nextcloud
|
||||||
|
@ -395,17 +396,17 @@ function remove_nextcloud {
|
||||||
remove_onion_service nextcloud ${NEXTCLOUD_ONION_PORT}
|
remove_onion_service nextcloud ${NEXTCLOUD_ONION_PORT}
|
||||||
remove_app nextcloud
|
remove_app nextcloud
|
||||||
remove_completion_param install_nextcloud
|
remove_completion_param install_nextcloud
|
||||||
sed -i '/nextcloud/d' $COMPLETION_FILE
|
sed -i '/nextcloud/d' "$COMPLETION_FILE"
|
||||||
remove_backup_database_local nextcloud
|
remove_backup_database_local nextcloud
|
||||||
|
|
||||||
function_check remove_ddns_domain
|
function_check remove_ddns_domain
|
||||||
remove_ddns_domain $NEXTCLOUD_DOMAIN_NAME
|
remove_ddns_domain "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
systemctl restart php7.0-fpm
|
systemctl restart php7.0-fpm
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_nextcloud_main {
|
function install_nextcloud_main {
|
||||||
if [ ! $NEXTCLOUD_DOMAIN_NAME ]; then
|
if [ ! "$NEXTCLOUD_DOMAIN_NAME" ]; then
|
||||||
echo $'No domain name was given for nextcloud'
|
echo $'No domain name was given for nextcloud'
|
||||||
exit 7359
|
exit 7359
|
||||||
fi
|
fi
|
||||||
|
@ -434,34 +435,34 @@ function install_nextcloud_main {
|
||||||
fi
|
fi
|
||||||
sed -i 's|;env[PATH]|env[PATH]|g' /etc/php/7.0/fpm/pool.d/www.conf
|
sed -i 's|;env[PATH]|env[PATH]|g' /etc/php/7.0/fpm/pool.d/www.conf
|
||||||
|
|
||||||
if [ ! -d /var/www/$NEXTCLOUD_DOMAIN_NAME ]; then
|
if [ ! -d "/var/www/$NEXTCLOUD_DOMAIN_NAME" ]; then
|
||||||
mkdir /var/www/$NEXTCLOUD_DOMAIN_NAME
|
mkdir "/var/www/$NEXTCLOUD_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ ! -d /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" ]; then
|
||||||
|
|
||||||
if [ -d /repos/nextcloud ]; then
|
if [ -d /repos/nextcloud ]; then
|
||||||
mkdir /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
mkdir "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
||||||
cp -r -p /repos/nextcloud/. /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
cp -r -p /repos/nextcloud/. "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
||||||
cd /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
cd "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" || exit 2783539793
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
git_clone $NEXTCLOUD_REPO /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
git_clone "$NEXTCLOUD_REPO" "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" ]; then
|
||||||
echo $'Unable to clone nextcloud repo'
|
echo $'Unable to clone nextcloud repo'
|
||||||
exit 87525
|
exit 87525
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
cd "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs" || exit 3468346834
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
git checkout $NEXTCLOUD_COMMIT -b $NEXTCLOUD_COMMIT
|
git checkout $NEXTCLOUD_COMMIT -b $NEXTCLOUD_COMMIT
|
||||||
set_completion_param "nextcloud commit" "$NEXTCLOUD_COMMIT"
|
set_completion_param "nextcloud commit" "$NEXTCLOUD_COMMIT"
|
||||||
|
|
||||||
chmod g+w /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
chmod g+w "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
||||||
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
|
chown -R www-data:www-data "/var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs"
|
||||||
|
|
||||||
function_check nextcloud_create_database
|
function_check nextcloud_create_database
|
||||||
nextcloud_create_database
|
nextcloud_create_database
|
||||||
|
@ -474,154 +475,154 @@ function install_nextcloud_main {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check add_ddns_domain
|
function_check add_ddns_domain
|
||||||
add_ddns_domain $NEXTCLOUD_DOMAIN_NAME
|
add_ddns_domain "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
|
|
||||||
nextcloud_nginx_site=/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME
|
nextcloud_nginx_site=/etc/nginx/sites-available/$NEXTCLOUD_DOMAIN_NAME
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $NEXTCLOUD_DOMAIN_NAME
|
nginx_http_redirect "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
echo 'server {' >> $nextcloud_nginx_site
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> $nextcloud_nginx_site
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> $nextcloud_nginx_site
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo " server_name $NEXTCLOUD_DOMAIN_NAME;" >> $nextcloud_nginx_site
|
echo " server_name $NEXTCLOUD_DOMAIN_NAME;";
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Security' >> $nextcloud_nginx_site
|
echo ' # Security'; } >> "$nextcloud_nginx_site"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $NEXTCLOUD_DOMAIN_NAME mobile
|
nginx_ssl "$NEXTCLOUD_DOMAIN_NAME" mobile
|
||||||
|
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $NEXTCLOUD_DOMAIN_NAME
|
nginx_disable_sniffing "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
|
|
||||||
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $nextcloud_nginx_site
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Logs' >> $nextcloud_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $nextcloud_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $nextcloud_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $nextcloud_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;" >> $nextcloud_nginx_site
|
echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Index' >> $nextcloud_nginx_site
|
echo ' # Index';
|
||||||
echo ' index index.php;' >> $nextcloud_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
|
|
||||||
# By default nextcloud advertises highly specific version information
|
# By default nextcloud advertises highly specific version information
|
||||||
# on status.php, which can obviously be used by adversaries.
|
# on status.php, which can obviously be used by adversaries.
|
||||||
# Blocking status.php prevents this information leak
|
# Blocking status.php prevents this information leak
|
||||||
echo ' location = /status.php {' >> $nextcloud_nginx_site
|
echo ' location = /status.php {';
|
||||||
echo ' return 404;' >> $nextcloud_nginx_site
|
echo ' return 404;';
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
|
|
||||||
echo ' # PHP' >> $nextcloud_nginx_site
|
echo ' # PHP';
|
||||||
echo ' location ~ \.php {' >> $nextcloud_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $nextcloud_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $nextcloud_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $nextcloud_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $nextcloud_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $nextcloud_nginx_site
|
echo ' location / {'; } >> "$nextcloud_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $NEXTCLOUD_DOMAIN_NAME '15m'
|
nginx_limits "$NEXTCLOUD_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @nextcloud;' >> $nextcloud_nginx_site
|
{ echo " try_files \$uri \$uri/ @nextcloud;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Fancy URLs' >> $nextcloud_nginx_site
|
echo ' # Fancy URLs';
|
||||||
echo ' location @nextcloud {' >> $nextcloud_nginx_site
|
echo ' location @nextcloud {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $nextcloud_nginx_site
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $nextcloud_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $nextcloud_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $nextcloud_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' location = /.well-known/carddav {' >> $nextcloud_nginx_site
|
echo ' location = /.well-known/carddav {';
|
||||||
echo ' return 301 $scheme://$host/remote.php/dav;' >> $nextcloud_nginx_site
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo ' location = /.well-known/caldav {' >> $nextcloud_nginx_site
|
echo ' location = /.well-known/caldav {';
|
||||||
echo ' return 301 $scheme://$host/remote.php/dav;' >> $nextcloud_nginx_site
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' location /.well-known/acme-challenge { }' >> $nextcloud_nginx_site
|
echo ' location /.well-known/acme-challenge { }';
|
||||||
echo '}' >> $nextcloud_nginx_site
|
echo '}'; } >> "$nextcloud_nginx_site"
|
||||||
else
|
else
|
||||||
echo -n '' > $nextcloud_nginx_site
|
echo -n '' > "$nextcloud_nginx_site"
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> $nextcloud_nginx_site
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:$NEXTCLOUD_ONION_PORT default_server;" >> $nextcloud_nginx_site
|
echo " listen 127.0.0.1:$NEXTCLOUD_ONION_PORT default_server;";
|
||||||
echo " server_name $NEXTCLOUD_DOMAIN_NAME;" >> $nextcloud_nginx_site
|
echo " server_name $NEXTCLOUD_DOMAIN_NAME;";
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo ''; } >> "$nextcloud_nginx_site"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $NEXTCLOUD_DOMAIN_NAME
|
nginx_disable_sniffing "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
echo '' >> $nextcloud_nginx_site
|
{ echo '';
|
||||||
echo ' # Logs' >> $nextcloud_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $nextcloud_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $nextcloud_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $nextcloud_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;" >> $nextcloud_nginx_site
|
echo " root /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Index' >> $nextcloud_nginx_site
|
echo ' # Index';
|
||||||
echo ' index index.php;' >> $nextcloud_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
|
|
||||||
# By default nextcloud advertises highly specific version information
|
# By default nextcloud advertises highly specific version information
|
||||||
# on status.php, which can obviously be used by adversaries.
|
# on status.php, which can obviously be used by adversaries.
|
||||||
# Blocking status.php prevents this information leak
|
# Blocking status.php prevents this information leak
|
||||||
echo ' location = /status.php {' >> $nextcloud_nginx_site
|
echo ' location = /status.php {';
|
||||||
echo ' return 404;' >> $nextcloud_nginx_site
|
echo ' return 404;';
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
|
|
||||||
echo ' # PHP' >> $nextcloud_nginx_site
|
echo ' # PHP';
|
||||||
echo ' location ~ \.php {' >> $nextcloud_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $nextcloud_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $nextcloud_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $nextcloud_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $nextcloud_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $nextcloud_nginx_site
|
echo ' location / {'; } >> "$nextcloud_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $NEXTCLOUD_DOMAIN_NAME '15m'
|
nginx_limits "$NEXTCLOUD_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @nextcloud;' >> $nextcloud_nginx_site
|
{ echo " try_files \$uri \$uri/ @nextcloud;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Fancy URLs' >> $nextcloud_nginx_site
|
echo ' # Fancy URLs';
|
||||||
echo ' location @nextcloud {' >> $nextcloud_nginx_site
|
echo ' location @nextcloud {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $nextcloud_nginx_site
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $nextcloud_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $nextcloud_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $nextcloud_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' location = /.well-known/carddav {' >> $nextcloud_nginx_site
|
echo ' location = /.well-known/carddav {';
|
||||||
echo ' return 301 $scheme://$host/remote.php/dav;' >> $nextcloud_nginx_site
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo ' location = /.well-known/caldav {' >> $nextcloud_nginx_site
|
echo ' location = /.well-known/caldav {';
|
||||||
echo ' return 301 $scheme://$host/remote.php/dav;' >> $nextcloud_nginx_site
|
echo " return 301 \$scheme://\$host/remote.php/dav;";
|
||||||
echo ' }' >> $nextcloud_nginx_site
|
echo ' }';
|
||||||
echo '' >> $nextcloud_nginx_site
|
echo '';
|
||||||
echo ' location /.well-known/acme-challenge { }' >> $nextcloud_nginx_site
|
echo ' location /.well-known/acme-challenge { }';
|
||||||
echo '}' >> $nextcloud_nginx_site
|
echo '}'; } >> "$nextcloud_nginx_site"
|
||||||
|
|
||||||
sed -i 's| DENY;| SAMEORIGIN;|g' $nextcloud_nginx_site
|
sed -i 's| DENY;| SAMEORIGIN;|g' "$nextcloud_nginx_site"
|
||||||
|
|
||||||
# NextCloud doesn't like content-security-policy at all
|
# NextCloud doesn't like content-security-policy at all
|
||||||
sed -i '/Content-Security-Policy/d' $nextcloud_nginx_site
|
sed -i '/Content-Security-Policy/d' "$nextcloud_nginx_site"
|
||||||
|
|
||||||
function_check configure_php
|
function_check configure_php
|
||||||
configure_php
|
configure_php
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate $NEXTCLOUD_DOMAIN_NAME 'yes'
|
create_site_certificate "$NEXTCLOUD_DOMAIN_NAME" 'yes'
|
||||||
|
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ "$ONION_ONLY" == "no" ]]; then
|
||||||
if [ ! -f /etc/ssl/certs/${NEXTCLOUD_DOMAIN_NAME}.pem ]; then
|
if [ ! -f "/etc/ssl/certs/${NEXTCLOUD_DOMAIN_NAME}.pem" ]; then
|
||||||
echo $'Certificate not generated for nextcloud'
|
echo $'Certificate not generated for nextcloud'
|
||||||
exit 725762
|
exit 725762
|
||||||
fi
|
fi
|
||||||
|
@ -636,31 +637,18 @@ function install_nextcloud_main {
|
||||||
backup_database_local nextcloud
|
backup_database_local nextcloud
|
||||||
|
|
||||||
function_check nginx_ensite
|
function_check nginx_ensite
|
||||||
nginx_ensite $NEXTCLOUD_DOMAIN_NAME
|
nginx_ensite "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
|
|
||||||
# NOTE: For the typical case always enable SSL and only
|
|
||||||
# disable it if in onion only mode. This is due to complexities
|
|
||||||
# with the way URLs are generated by nextcloud
|
|
||||||
nextcloud_ssl='always'
|
|
||||||
if [[ $ONION_ONLY != 'no' ]]; then
|
|
||||||
nextcloud_ssl='never'
|
|
||||||
fi
|
|
||||||
|
|
||||||
NEXTCLOUD_ONION_HOSTNAME=$(add_onion_service nextcloud 80 ${NEXTCLOUD_ONION_PORT})
|
NEXTCLOUD_ONION_HOSTNAME=$(add_onion_service nextcloud 80 ${NEXTCLOUD_ONION_PORT})
|
||||||
|
|
||||||
NEXTCLOUD_SERVER=${NEXTCLOUD_DOMAIN_NAME}
|
|
||||||
if [[ $ONION_ONLY != 'no' ]]; then
|
|
||||||
NEXTCLOUD_SERVER=${NEXTCLOUD_ONION_HOSTNAME}
|
|
||||||
fi
|
|
||||||
|
|
||||||
systemctl restart php7.0-fpm
|
systemctl restart php7.0-fpm
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$NEXTCLOUD_DOMAIN_NAME" -g nextcloud --public no
|
"${PROJECT_NAME}-addemail" -u "$MY_USERNAME" -e "noreply@$NEXTCLOUD_DOMAIN_NAME" -g nextcloud --public no
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a nextcloud -p "$NEXTCLOUD_ADMIN_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a nextcloud -p "$NEXTCLOUD_ADMIN_PASSWORD"
|
||||||
|
|
||||||
cd /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
cd "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs" || exit 2467245247
|
||||||
if [ -d config ]; then
|
if [ -d config ]; then
|
||||||
chown -R www-data:www-data config
|
chown -R www-data:www-data config
|
||||||
fi
|
fi
|
||||||
|
@ -669,7 +657,7 @@ function install_nextcloud_main {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod +x occ
|
chmod +x occ
|
||||||
./occ maintenance:install --database-name nextcloud --admin-user ${MY_USERNAME} --admin-pass "${NEXTCLOUD_ADMIN_PASSWORD}" --database mysql --database-user root --database-pass "${MARIADB_PASSWORD}"
|
./occ maintenance:install --database-name nextcloud --admin-user "${MY_USERNAME}" --admin-pass "${NEXTCLOUD_ADMIN_PASSWORD}" --database mysql --database-user root --database-pass "${MARIADB_PASSWORD}"
|
||||||
if [ ! -d data ]; then
|
if [ ! -d data ]; then
|
||||||
echo $'Nextcloud data directory was not found. This probably means that the installation failed.'
|
echo $'Nextcloud data directory was not found. This probably means that the installation failed.'
|
||||||
echo ''
|
echo ''
|
||||||
|
@ -683,20 +671,19 @@ function install_nextcloud_main {
|
||||||
sudo -u www-data ./occ status
|
sudo -u www-data ./occ status
|
||||||
sudo -u www-data ./occ app:list
|
sudo -u www-data ./occ app:list
|
||||||
sudo -u www-data ./occ app:enable encryption
|
sudo -u www-data ./occ app:enable encryption
|
||||||
sudo -u www-data ./occ encryption:enable
|
if ! sudo -u www-data ./occ encryption:enable; then
|
||||||
if [ ! "$?" = "0" ]; then
|
|
||||||
echo $'Encryption not enabled'
|
echo $'Encryption not enabled'
|
||||||
exit 73527
|
exit 73527
|
||||||
fi
|
fi
|
||||||
sudo -u www-data ./occ encryption:status
|
sudo -u www-data ./occ encryption:status
|
||||||
sudo -u www-data ./occ config:system:set appstoreenabled --value=false
|
sudo -u www-data ./occ config:system:set appstoreenabled --value=false
|
||||||
chmod g+w /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php
|
chmod g+w "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php"
|
||||||
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
|
||||||
chmod 0644 .htaccess
|
chmod 0644 .htaccess
|
||||||
chmod 0750 data
|
chmod 0750 data
|
||||||
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/data
|
chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/data"
|
||||||
sudo -u www-data ./occ config:system:set trusted_domains 1 --value=$NEXTCLOUD_DOMAIN_NAME
|
sudo -u www-data ./occ config:system:set trusted_domains 1 --value="$NEXTCLOUD_DOMAIN_NAME"
|
||||||
sudo -u www-data ./occ config:system:set trusted_domains 2 --value=$NEXTCLOUD_ONION_HOSTNAME
|
sudo -u www-data ./occ config:system:set trusted_domains 2 --value="$NEXTCLOUD_ONION_HOSTNAME"
|
||||||
sudo -u www-data ./occ files:cleanup
|
sudo -u www-data ./occ files:cleanup
|
||||||
sudo -u www-data ./occ files:scan --all
|
sudo -u www-data ./occ files:scan --all
|
||||||
sudo -u www-data ./occ maintenance:repair
|
sudo -u www-data ./occ maintenance:repair
|
||||||
|
@ -705,8 +692,8 @@ function install_nextcloud_main {
|
||||||
systemctl restart mariadb
|
systemctl restart mariadb
|
||||||
|
|
||||||
# move the data directory
|
# move the data directory
|
||||||
mv /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
|
mv "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/data" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/"
|
||||||
sed -i "s|'datadirectory'.*|'datadirectory' => '/var/www/$NEXTCLOUD_DOMAIN_NAME/data',|g" /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php
|
sed -i "s|'datadirectory'.*|'datadirectory' => '/var/www/$NEXTCLOUD_DOMAIN_NAME/data',|g" "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php"
|
||||||
|
|
||||||
set_completion_param "nextcloud domain" "$NEXTCLOUD_DOMAIN_NAME"
|
set_completion_param "nextcloud domain" "$NEXTCLOUD_DOMAIN_NAME"
|
||||||
|
|
||||||
|
@ -714,7 +701,7 @@ function install_nextcloud_main {
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_nextcloud {
|
function install_nextcloud {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -55,14 +55,14 @@ peertube_variables=(PEERTUBE_DOMAIN_NAME
|
||||||
MY_EMAIL_ADDRESS)
|
MY_EMAIL_ADDRESS)
|
||||||
|
|
||||||
function peertube_create_database {
|
function peertube_create_database {
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
PEERTUBE_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
PEERTUBE_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
if [ ! $PEERTUBE_ADMIN_PASSWORD ]; then
|
if [ ! "$PEERTUBE_ADMIN_PASSWORD" ]; then
|
||||||
PEERTUBE_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
PEERTUBE_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! $PEERTUBE_ADMIN_PASSWORD ]; then
|
if [ ! "$PEERTUBE_ADMIN_PASSWORD" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -82,7 +82,8 @@ function logging_off_peertube {
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_user_peertube {
|
function remove_user_peertube {
|
||||||
remove_username="$1"
|
echo -n ''
|
||||||
|
# remove_username="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_user_peertube {
|
function add_user_peertube {
|
||||||
|
@ -91,14 +92,14 @@ function add_user_peertube {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new_username="$1"
|
# new_username="$1"
|
||||||
new_user_password="$2"
|
# new_user_password="$2"
|
||||||
|
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_interactive_peertube {
|
function install_interactive_peertube {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -113,15 +114,14 @@ function install_interactive_peertube {
|
||||||
}
|
}
|
||||||
|
|
||||||
function peertube_set_admin_email {
|
function peertube_set_admin_email {
|
||||||
read_config_param $MY_EMAIL_ADDRESS
|
read_config_param "$MY_EMAIL_ADDRESS"
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --title $"Set PeerTube administrator email address" \
|
dialog --title $"Set PeerTube administrator email address" \
|
||||||
--backtitle $"Freedombone Control Panel" \
|
--backtitle $"Freedombone Control Panel" \
|
||||||
--inputbox $"Admin email address" 8 75 "$MY_EMAIL_ADDRESS" 2>$data
|
--inputbox $"Admin email address" 8 75 "$MY_EMAIL_ADDRESS" 2>"$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
0) peertube_email=$(<$data)
|
0) peertube_email=$(<"$data")
|
||||||
if [[ "$peertube_email" != *' '* && "$peertube_email" != *','* && "$peertube_email" != *';'* && "$peertube_email" == *'@'* && "$peertube_email" == *'.'* ]]; then
|
if [[ "$peertube_email" != *' '* && "$peertube_email" != *','* && "$peertube_email" != *';'* && "$peertube_email" == *'@'* && "$peertube_email" == *'.'* ]]; then
|
||||||
if [ ${#peertube_email} -gt 8 ]; then
|
if [ ${#peertube_email} -gt 8 ]; then
|
||||||
sed -i "s|email:.*|email: '${peertube_email}'|g" $PEERTUBE_DIR/config/production.yaml
|
sed -i "s|email:.*|email: '${peertube_email}'|g" $PEERTUBE_DIR/config/production.yaml
|
||||||
|
@ -132,13 +132,13 @@ function peertube_set_admin_email {
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
rm $data
|
rm -f "$data"
|
||||||
}
|
}
|
||||||
|
|
||||||
function peertube_disable_signups {
|
function peertube_disable_signups {
|
||||||
dialog --title $"Disable PeerTube signups" \
|
dialog --title $"Disable PeerTube signups" \
|
||||||
--backtitle $"Freedombone Control Panel" \
|
--backtitle $"Freedombone Control Panel" \
|
||||||
--yesno $"\nDo you wish to disable further PeerTube signups?" 8 75
|
--yesno $"\\nDo you wish to disable further PeerTube signups?" 8 75
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
0) sed -i "0,/enabled:.*/s//enabled: false/" $PEERTUBE_DIR/config/production.yaml;;
|
0) sed -i "0,/enabled:.*/s//enabled: false/" $PEERTUBE_DIR/config/production.yaml;;
|
||||||
|
@ -152,35 +152,36 @@ function peertube_disable_signups {
|
||||||
function configure_interactive_peertube {
|
function configure_interactive_peertube {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
dialog --backtitle $"Freedombone Control Panel" \
|
||||||
--title $"PeerTube" \
|
--title $"PeerTube" \
|
||||||
--radiolist $"Choose an operation:" 10 70 4 \
|
--radiolist $"Choose an operation:" 10 70 4 \
|
||||||
1 $"Set administrator email address" off \
|
1 $"Set administrator email address" off \
|
||||||
2 $"Disable or enable signups" off \
|
2 $"Disable or enable signups" off \
|
||||||
3 $"Exit" on 2> $data
|
3 $"Exit" on 2> "$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) break;;
|
1) break;;
|
||||||
255) break;;
|
255) break;;
|
||||||
esac
|
esac
|
||||||
case $(cat $data) in
|
case $(cat "$data") in
|
||||||
1) peertube_set_admin_email;;
|
1) peertube_set_admin_email;;
|
||||||
2) peertube_disable_signups;;
|
2) peertube_disable_signups;;
|
||||||
3) break;;
|
3) rm -f "$data"
|
||||||
|
break;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_password_peertube {
|
function change_password_peertube {
|
||||||
PEERTUBE_USERNAME="$1"
|
# PEERTUBE_USERNAME="$1"
|
||||||
PEERTUBE_PASSWORD="$2"
|
PEERTUBE_PASSWORD="$2"
|
||||||
if [ ${#PEERTUBE_PASSWORD} -lt 8 ]; then
|
if [ ${#PEERTUBE_PASSWORD} -lt 8 ]; then
|
||||||
echo $'Peertube password is too short'
|
echo $'Peertube password is too short'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
#${PROJECT_NAME}-pass -u $PEERTUBE_USERNAME -a peertube -p "$PEERTUBE_PASSWORD"
|
#"${PROJECT_NAME}-pass" -u "$PEERTUBE_USERNAME" -a peertube -p "$PEERTUBE_PASSWORD"
|
||||||
}
|
}
|
||||||
|
|
||||||
function reconfigure_peertube {
|
function reconfigure_peertube {
|
||||||
|
@ -195,7 +196,7 @@ function upgrade_peertube {
|
||||||
|
|
||||||
read_config_param PEERTUBE_DOMAIN_NAME
|
read_config_param PEERTUBE_DOMAIN_NAME
|
||||||
systemctl stop peertube
|
systemctl stop peertube
|
||||||
cd $PEERTUBE_DIR
|
cd "$PEERTUBE_DIR" || exit 7824552627
|
||||||
|
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit $PEERTUBE_DIR "peertube commit" "$PEERTUBE_COMMIT" $PEERTUBE_REPO
|
set_repo_commit $PEERTUBE_DIR "peertube commit" "$PEERTUBE_COMMIT" $PEERTUBE_REPO
|
||||||
|
@ -207,7 +208,7 @@ function upgrade_peertube {
|
||||||
|
|
||||||
function backup_local_peertube {
|
function backup_local_peertube {
|
||||||
PEERTUBE_DOMAIN_NAME='peertube.local'
|
PEERTUBE_DOMAIN_NAME='peertube.local'
|
||||||
if grep -q "peertube domain" $COMPLETION_FILE; then
|
if grep -q "peertube domain" "$COMPLETION_FILE"; then
|
||||||
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -219,7 +220,7 @@ function backup_local_peertube {
|
||||||
|
|
||||||
peertube_path=$PEERTUBE_DIR/videos
|
peertube_path=$PEERTUBE_DIR/videos
|
||||||
if [ -d $peertube_path ]; then
|
if [ -d $peertube_path ]; then
|
||||||
suspend_site ${PEERTUBE_DOMAIN_NAME}
|
suspend_site "${PEERTUBE_DOMAIN_NAME}"
|
||||||
systemctl stop peertube
|
systemctl stop peertube
|
||||||
backup_directory_to_usb $peertube_path peertubevideos
|
backup_directory_to_usb $peertube_path peertubevideos
|
||||||
systemctl start peertube
|
systemctl start peertube
|
||||||
|
@ -229,11 +230,11 @@ function backup_local_peertube {
|
||||||
|
|
||||||
function restore_local_peertube {
|
function restore_local_peertube {
|
||||||
PEERTUBE_DOMAIN_NAME='peertube.local'
|
PEERTUBE_DOMAIN_NAME='peertube.local'
|
||||||
if grep -q "peertube domain" $COMPLETION_FILE; then
|
if grep -q "peertube domain" "$COMPLETION_FILE"; then
|
||||||
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
||||||
fi
|
fi
|
||||||
if [ $PEERTUBE_DOMAIN_NAME ]; then
|
if [ "$PEERTUBE_DOMAIN_NAME" ]; then
|
||||||
suspend_site ${PEERTUBE_DOMAIN_NAME}
|
suspend_site "${PEERTUBE_DOMAIN_NAME}"
|
||||||
systemctl stop peertube
|
systemctl stop peertube
|
||||||
|
|
||||||
USE_POSTGRESQL=1
|
USE_POSTGRESQL=1
|
||||||
|
@ -259,7 +260,7 @@ function restore_local_peertube {
|
||||||
|
|
||||||
function backup_remote_peertube {
|
function backup_remote_peertube {
|
||||||
PEERTUBE_DOMAIN_NAME='peertube.local'
|
PEERTUBE_DOMAIN_NAME='peertube.local'
|
||||||
if grep -q "peertube domain" $COMPLETION_FILE; then
|
if grep -q "peertube domain" "$COMPLETION_FILE"; then
|
||||||
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ function backup_remote_peertube {
|
||||||
temp_backup_dir=$PEERTUBE_DIR/videos
|
temp_backup_dir=$PEERTUBE_DIR/videos
|
||||||
if [ -d $temp_backup_dir ]; then
|
if [ -d $temp_backup_dir ]; then
|
||||||
systemctl stop peertube
|
systemctl stop peertube
|
||||||
suspend_site ${PEERTUBE_DOMAIN_NAME}
|
suspend_site "${PEERTUBE_DOMAIN_NAME}"
|
||||||
backup_directory_to_friend $temp_backup_dir peertubevideos
|
backup_directory_to_friend $temp_backup_dir peertubevideos
|
||||||
restart_site
|
restart_site
|
||||||
systemctl start peertube
|
systemctl start peertube
|
||||||
|
@ -284,13 +285,14 @@ function backup_remote_peertube {
|
||||||
|
|
||||||
function restore_remote_peertube {
|
function restore_remote_peertube {
|
||||||
PEERTUBE_DOMAIN_NAME='peertube.local'
|
PEERTUBE_DOMAIN_NAME='peertube.local'
|
||||||
if grep -q "peertube domain" $COMPLETION_FILE; then
|
if grep -q "peertube domain" "$COMPLETION_FILE"; then
|
||||||
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
|
||||||
fi
|
fi
|
||||||
suspend_site ${PEERTUBE_DOMAIN_NAME}
|
suspend_site "${PEERTUBE_DOMAIN_NAME}"
|
||||||
|
|
||||||
systemctl stop peertube
|
systemctl stop peertube
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
USE_POSTGRESQL=1
|
USE_POSTGRESQL=1
|
||||||
function_check restore_database_from_friend
|
function_check restore_database_from_friend
|
||||||
restore_database_from_friend peertube
|
restore_database_from_friend peertube
|
||||||
|
@ -326,20 +328,20 @@ function remove_peertube {
|
||||||
remove_nodejs peertube
|
remove_nodejs peertube
|
||||||
|
|
||||||
read_config_param "PEERTUBE_DOMAIN_NAME"
|
read_config_param "PEERTUBE_DOMAIN_NAME"
|
||||||
nginx_dissite $PEERTUBE_DOMAIN_NAME
|
nginx_dissite "$PEERTUBE_DOMAIN_NAME"
|
||||||
remove_certs ${PEERTUBE_DOMAIN_NAME}
|
remove_certs "${PEERTUBE_DOMAIN_NAME}"
|
||||||
if [ -f /etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME ]; then
|
if [ -f "/etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME" ]; then
|
||||||
rm -f /etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME
|
rm -f "/etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ -d /var/www/$PEERTUBE_DOMAIN_NAME ]; then
|
if [ -d "/var/www/$PEERTUBE_DOMAIN_NAME" ]; then
|
||||||
rm -rf /var/www/$PEERTUBE_DOMAIN_NAME
|
rm -rf "/var/www/$PEERTUBE_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
remove_config_param PEERTUBE_DOMAIN_NAME
|
remove_config_param PEERTUBE_DOMAIN_NAME
|
||||||
remove_config_param PEERTUBE_CODE
|
remove_config_param PEERTUBE_CODE
|
||||||
function_check remove_onion_service
|
function_check remove_onion_service
|
||||||
remove_onion_service peertube ${PEERTUBE_ONION_PORT}
|
remove_onion_service peertube ${PEERTUBE_ONION_PORT}
|
||||||
remove_completion_param "install_peertube"
|
remove_completion_param "install_peertube"
|
||||||
sed -i '/peertube/d' $COMPLETION_FILE
|
sed -i '/peertube/d' "$COMPLETION_FILE"
|
||||||
|
|
||||||
function_check drop_database_postgresql
|
function_check drop_database_postgresql
|
||||||
drop_database_postgresql peertube peertube
|
drop_database_postgresql peertube peertube
|
||||||
|
@ -352,188 +354,189 @@ function remove_peertube {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check remove_ddns_domain
|
function_check remove_ddns_domain
|
||||||
remove_ddns_domain $PEERTUBE_DOMAIN_NAME
|
remove_ddns_domain "$PEERTUBE_DOMAIN_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function peertube_setup_web {
|
function peertube_setup_web {
|
||||||
peertube_nginx_file=/etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME
|
peertube_nginx_file=/etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME
|
||||||
|
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
echo 'server {' > $peertube_nginx_file
|
{ echo 'server {';
|
||||||
echo ' listen 80;' >> $peertube_nginx_file
|
echo ' listen 80;';
|
||||||
echo ' listen [::]:80;' >> $peertube_nginx_file
|
echo ' listen [::]:80;';
|
||||||
echo " server_name $PEERTUBE_DOMAIN_NAME;" >> $peertube_nginx_file
|
echo " server_name $PEERTUBE_DOMAIN_NAME;";
|
||||||
echo ' rewrite ^ https://$server_name$request_uri? permanent;' >> $peertube_nginx_file
|
echo " rewrite ^ https://\$server_name\$request_uri? permanent;";
|
||||||
echo '}' >> $peertube_nginx_file
|
echo '}';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo 'server {' >> $peertube_nginx_file
|
echo 'server {';
|
||||||
echo ' listen 443 ssl http2;' >> $peertube_nginx_file
|
echo ' listen 443 ssl http2;';
|
||||||
echo ' #listen [::]:443 ssl http2;' >> $peertube_nginx_file
|
echo ' #listen [::]:443 ssl http2;';
|
||||||
echo " server_name $PEERTUBE_DOMAIN_NAME;" >> $peertube_nginx_file
|
echo " server_name $PEERTUBE_DOMAIN_NAME;";
|
||||||
echo '' >> $peertube_nginx_file
|
echo ''; } > "$peertube_nginx_file"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $PEERTUBE_DOMAIN_NAME mobile
|
nginx_ssl "$PEERTUBE_DOMAIN_NAME" mobile
|
||||||
|
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $PEERTUBE_DOMAIN_NAME
|
nginx_disable_sniffing "$PEERTUBE_DOMAIN_NAME"
|
||||||
|
|
||||||
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $peertube_nginx_file
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' location / {' >> $peertube_nginx_file
|
echo ' location / {';
|
||||||
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
echo " proxy_pass http://localhost:${PEERTUBE_PORT};";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' # For the video upload' >> $peertube_nginx_file
|
echo ' # For the video upload';
|
||||||
echo ' client_max_body_size 2G;' >> $peertube_nginx_file
|
echo ' client_max_body_size 2G;';
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' location /static/webseed {' >> $peertube_nginx_file
|
echo ' location /static/webseed {';
|
||||||
echo " if (\$request_method = 'OPTIONS') {" >> $peertube_nginx_file
|
echo " if (\$request_method = 'OPTIONS') {";
|
||||||
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Origin' '*';";
|
||||||
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';";
|
||||||
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';";
|
||||||
echo " add_header 'Access-Control-Max-Age' 1728000;" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Max-Age' 1728000;";
|
||||||
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';" >> $peertube_nginx_file
|
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';";
|
||||||
echo " add_header 'Content-Length' 0;" >> $peertube_nginx_file
|
echo " add_header 'Content-Length' 0;";
|
||||||
echo ' return 204;' >> $peertube_nginx_file
|
echo ' return 204;';
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo " if (\$request_method = 'GET') {" >> $peertube_nginx_file
|
echo " if (\$request_method = 'GET') {";
|
||||||
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Origin' '*';";
|
||||||
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';";
|
||||||
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo " alias $PEERTUBE_DIR/videos;" >> $peertube_nginx_file
|
echo " alias $PEERTUBE_DIR/videos;";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' # Websocket tracker' >> $peertube_nginx_file
|
echo ' # Websocket tracker';
|
||||||
echo ' location /tracker/socket {' >> $peertube_nginx_file
|
echo ' location /tracker/socket {';
|
||||||
echo ' # Peers send a message to the tracker every 15 minutes' >> $peertube_nginx_file
|
echo ' # Peers send a message to the tracker every 15 minutes';
|
||||||
echo ' # Dont close the websocket before this time' >> $peertube_nginx_file
|
echo ' # Dont close the websocket before this time';
|
||||||
echo ' proxy_read_timeout 1200s;' >> $peertube_nginx_file
|
echo ' proxy_read_timeout 1200s;';
|
||||||
echo ' proxy_set_header Upgrade $http_upgrade;' >> $peertube_nginx_file
|
echo " proxy_set_header Upgrade \$http_upgrade;";
|
||||||
echo ' proxy_set_header Connection "upgrade";' >> $peertube_nginx_file
|
echo ' proxy_set_header Connection "upgrade";';
|
||||||
echo ' proxy_http_version 1.1;' >> $peertube_nginx_file
|
echo ' proxy_http_version 1.1;';
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
echo " proxy_set_header Host \$host;";
|
||||||
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
echo " proxy_pass http://localhost:${PEERTUBE_PORT};";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '}' >> $peertube_nginx_file
|
echo '}'; } >> "$peertube_nginx_file"
|
||||||
else
|
else
|
||||||
echo -n '' > $peertube_nginx_file
|
echo -n '' > "$peertube_nginx_file"
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> $peertube_nginx_file
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:$PEERTUBE_ONION_PORT default_server;" >> $peertube_nginx_file
|
echo " listen 127.0.0.1:$PEERTUBE_ONION_PORT default_server;";
|
||||||
echo " server_name $PEERTUBE_ONION_HOSTNAME;" >> $peertube_nginx_file
|
echo " server_name $PEERTUBE_ONION_HOSTNAME;";
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' location / {' >> $peertube_nginx_file
|
echo ' location / {';
|
||||||
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
echo " proxy_pass http://localhost:${PEERTUBE_PORT};";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' # For the video upload' >> $peertube_nginx_file
|
echo ' # For the video upload';
|
||||||
echo ' client_max_body_size 2G;' >> $peertube_nginx_file
|
echo ' client_max_body_size 2G;';
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' location /static/webseed {' >> $peertube_nginx_file
|
echo ' location /static/webseed {';
|
||||||
echo " if (\$request_method = 'OPTIONS') {" >> $peertube_nginx_file
|
echo " if (\$request_method = 'OPTIONS') {";
|
||||||
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Origin' '*';";
|
||||||
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';";
|
||||||
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';";
|
||||||
echo " add_header 'Access-Control-Max-Age' 1728000;" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Max-Age' 1728000;";
|
||||||
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';" >> $peertube_nginx_file
|
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';";
|
||||||
echo " add_header 'Content-Length' 0;" >> $peertube_nginx_file
|
echo " add_header 'Content-Length' 0;";
|
||||||
echo ' return 204;' >> $peertube_nginx_file
|
echo ' return 204;';
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo " if (\$request_method = 'GET') {" >> $peertube_nginx_file
|
echo " if (\$request_method = 'GET') {";
|
||||||
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Origin' '*';";
|
||||||
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';";
|
||||||
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo " alias $PEERTUBE_DIR/videos;" >> $peertube_nginx_file
|
echo " alias $PEERTUBE_DIR/videos;";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' # Websocket tracker' >> $peertube_nginx_file
|
echo ' # Websocket tracker';
|
||||||
echo ' location /tracker/socket {' >> $peertube_nginx_file
|
echo ' location /tracker/socket {';
|
||||||
echo ' # Peers send a message to the tracker every 15 minutes' >> $peertube_nginx_file
|
echo ' # Peers send a message to the tracker every 15 minutes';
|
||||||
echo ' # Dont close the websocket before this time' >> $peertube_nginx_file
|
echo ' # Dont close the websocket before this time';
|
||||||
echo ' proxy_read_timeout 1200s;' >> $peertube_nginx_file
|
echo ' proxy_read_timeout 1200s;';
|
||||||
echo ' proxy_set_header Upgrade $http_upgrade;' >> $peertube_nginx_file
|
echo " proxy_set_header Upgrade \$http_upgrade;";
|
||||||
echo ' proxy_set_header Connection "upgrade";' >> $peertube_nginx_file
|
echo ' proxy_set_header Connection "upgrade";';
|
||||||
echo ' proxy_http_version 1.1;' >> $peertube_nginx_file
|
echo ' proxy_http_version 1.1;';
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
echo " proxy_set_header Host \$host;";
|
||||||
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
echo " proxy_pass http://localhost:${PEERTUBE_PORT};";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '}' >> $peertube_nginx_file
|
echo '}'; } >> "$peertube_nginx_file"
|
||||||
|
|
||||||
# CSP currently causes an error
|
# CSP currently causes an error
|
||||||
sed -i '/Content-Security-Policy/d' $peertube_nginx_file
|
sed -i '/Content-Security-Policy/d' "$peertube_nginx_file"
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate $PEERTUBE_DOMAIN_NAME 'yes'
|
create_site_certificate "$PEERTUBE_DOMAIN_NAME" 'yes'
|
||||||
|
|
||||||
function_check nginx_ensite
|
function_check nginx_ensite
|
||||||
nginx_ensite $PEERTUBE_DOMAIN_NAME
|
nginx_ensite "$PEERTUBE_DOMAIN_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mesh_peertube_setup_web {
|
function mesh_peertube_setup_web {
|
||||||
|
# shellcheck disable=SC2154
|
||||||
peertube_nginx_file=$rootdir/etc/nginx/sites-available/peertube
|
peertube_nginx_file=$rootdir/etc/nginx/sites-available/peertube
|
||||||
|
|
||||||
echo 'server {' >> $peertube_nginx_file
|
{ echo 'server {';
|
||||||
echo " listen $MESH_PEERTUBE_PORT http2;" >> $peertube_nginx_file
|
echo " listen $MESH_PEERTUBE_PORT http2;";
|
||||||
echo ' listen [::]:$MESH_PEERTUBE_PORT http2;' >> $peertube_nginx_file
|
echo " listen [::]:\$MESH_PEERTUBE_PORT http2;";
|
||||||
echo ' server_name $HOSTNAME;' >> $peertube_nginx_file
|
echo " server_name \$HOSTNAME;";
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' location / {' >> $peertube_nginx_file
|
echo ' location / {';
|
||||||
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
echo " proxy_pass http://localhost:${PEERTUBE_PORT};";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' # For the video upload' >> $peertube_nginx_file
|
echo ' # For the video upload';
|
||||||
echo ' client_max_body_size 2G;' >> $peertube_nginx_file
|
echo ' client_max_body_size 2G;';
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' location /static/webseed {' >> $peertube_nginx_file
|
echo ' location /static/webseed {';
|
||||||
echo " if (\$request_method = 'OPTIONS') {" >> $peertube_nginx_file
|
echo " if (\$request_method = 'OPTIONS') {";
|
||||||
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Origin' '*';";
|
||||||
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';";
|
||||||
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';";
|
||||||
echo " add_header 'Access-Control-Max-Age' 1728000;" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Max-Age' 1728000;";
|
||||||
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';" >> $peertube_nginx_file
|
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';";
|
||||||
echo " add_header 'Content-Length' 0;" >> $peertube_nginx_file
|
echo " add_header 'Content-Length' 0;";
|
||||||
echo ' return 204;' >> $peertube_nginx_file
|
echo ' return 204;';
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo " if (\$request_method = 'GET') {" >> $peertube_nginx_file
|
echo " if (\$request_method = 'GET') {";
|
||||||
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Origin' '*';";
|
||||||
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';";
|
||||||
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo " alias $PEERTUBE_DIR/videos;" >> $peertube_nginx_file
|
echo " alias $PEERTUBE_DIR/videos;";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '' >> $peertube_nginx_file
|
echo '';
|
||||||
echo ' # Websocket tracker' >> $peertube_nginx_file
|
echo ' # Websocket tracker';
|
||||||
echo ' location /tracker/socket {' >> $peertube_nginx_file
|
echo ' location /tracker/socket {';
|
||||||
echo ' # Peers send a message to the tracker every 15 minutes' >> $peertube_nginx_file
|
echo ' # Peers send a message to the tracker every 15 minutes';
|
||||||
echo ' # Dont close the websocket before this time' >> $peertube_nginx_file
|
echo ' # Dont close the websocket before this time';
|
||||||
echo ' proxy_read_timeout 1200s;' >> $peertube_nginx_file
|
echo ' proxy_read_timeout 1200s;';
|
||||||
echo ' proxy_set_header Upgrade $http_upgrade;' >> $peertube_nginx_file
|
echo " proxy_set_header Upgrade \$http_upgrade;";
|
||||||
echo ' proxy_set_header Connection "upgrade";' >> $peertube_nginx_file
|
echo " proxy_set_header Connection \"upgrade\";";
|
||||||
echo ' proxy_http_version 1.1;' >> $peertube_nginx_file
|
echo ' proxy_http_version 1.1;';
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
echo " proxy_set_header Host \$host;";
|
||||||
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
echo " proxy_pass http://localhost:${PEERTUBE_PORT};";
|
||||||
echo ' }' >> $peertube_nginx_file
|
echo ' }';
|
||||||
echo '}' >> $peertube_nginx_file
|
echo '}'; } > "$peertube_nginx_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
function peertube_create_config {
|
function peertube_create_config {
|
||||||
|
@ -541,84 +544,84 @@ function peertube_create_config {
|
||||||
|
|
||||||
peertube_config_file=$peertube_prefix$PEERTUBE_DIR/config/production.yaml
|
peertube_config_file=$peertube_prefix$PEERTUBE_DIR/config/production.yaml
|
||||||
|
|
||||||
echo 'listen:' > $peertube_config_file
|
{ echo 'listen:';
|
||||||
echo " port: $PEERTUBE_PORT" >> $peertube_config_file
|
echo " port: $PEERTUBE_PORT";
|
||||||
echo '' >> $peertube_config_file
|
echo '';
|
||||||
echo '# Correspond to your reverse proxy "listen" configuration' >> $peertube_config_file
|
echo '# Correspond to your reverse proxy "listen" configuration';
|
||||||
echo 'webserver:' >> $peertube_config_file
|
echo 'webserver:'; } > "$peertube_config_file"
|
||||||
if [ ! $peertube_prefix ]; then
|
if [ ! "$peertube_prefix" ]; then
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ "$ONION_ONLY" == 'no' ]]; then
|
||||||
echo ' https: true' >> $peertube_config_file
|
{ echo ' https: true';
|
||||||
echo " hostname: '$PEERTUBE_DOMAIN_NAME'" >> $peertube_config_file
|
echo " hostname: '$PEERTUBE_DOMAIN_NAME'";
|
||||||
echo ' port: 443' >> $peertube_config_file
|
echo ' port: 443'; } >> "$peertube_config_file"
|
||||||
else
|
else
|
||||||
echo ' https: false' >> $peertube_config_file
|
{ echo ' https: false';
|
||||||
echo " hostname: '$PEERTUBE_ONION_HOSTNAME'" >> $peertube_config_file
|
echo " hostname: '$PEERTUBE_ONION_HOSTNAME'";
|
||||||
echo ' port: 80' >> $peertube_config_file
|
echo ' port: 80'; } >> "$peertube_config_file"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo ' https: false' >> $peertube_config_file
|
{ echo ' https: false';
|
||||||
echo " hostname: ''" >> $peertube_config_file
|
echo " hostname: ''";
|
||||||
echo " port: $MESH_PEERTUBE_PORT" >> $peertube_config_file
|
echo " port: $MESH_PEERTUBE_PORT"; } >> "$peertube_config_file"
|
||||||
fi
|
fi
|
||||||
echo '' >> $peertube_config_file
|
{ echo '';
|
||||||
echo '# Your database name will be "peertube"+database.suffix' >> $peertube_config_file
|
echo '# Your database name will be "peertube"+database.suffix';
|
||||||
echo 'database:' >> $peertube_config_file
|
echo 'database:';
|
||||||
echo " hostname: 'localhost'" >> $peertube_config_file
|
echo " hostname: 'localhost'";
|
||||||
echo ' port: 5432' >> $peertube_config_file
|
echo ' port: 5432';
|
||||||
echo " suffix: ''" >> $peertube_config_file
|
echo " suffix: ''";
|
||||||
echo " username: 'peertube'" >> $peertube_config_file
|
echo " username: 'peertube'"; } >> "$peertube_config_file"
|
||||||
if [ ! $peertube_prefix ]; then
|
if [ ! "$peertube_prefix" ]; then
|
||||||
echo " password: '$PEERTUBE_ADMIN_PASSWORD'" >> $peertube_config_file
|
echo " password: '$PEERTUBE_ADMIN_PASSWORD'" >> "$peertube_config_file"
|
||||||
else
|
else
|
||||||
echo " password: ''" >> $peertube_config_file
|
echo " password: ''" >> "$peertube_config_file"
|
||||||
fi
|
fi
|
||||||
echo '' >> $peertube_config_file
|
{ echo '';
|
||||||
echo '# From the project root directory' >> $peertube_config_file
|
echo '# From the project root directory';
|
||||||
echo 'storage:' >> $peertube_config_file
|
echo 'storage:';
|
||||||
echo " certs: 'certs/'" >> $peertube_config_file
|
echo " certs: 'certs/'";
|
||||||
echo " videos: 'videos/'" >> $peertube_config_file
|
echo " videos: 'videos/'";
|
||||||
echo " logs: 'logs/'" >> $peertube_config_file
|
echo " logs: 'logs/'";
|
||||||
echo " previews: 'previews/'" >> $peertube_config_file
|
echo " previews: 'previews/'";
|
||||||
echo " thumbnails: 'thumbnails/'" >> $peertube_config_file
|
echo " thumbnails: 'thumbnails/'";
|
||||||
echo " torrents: 'torrents/'" >> $peertube_config_file
|
echo " torrents: 'torrents/'";
|
||||||
echo " cache: 'cache/'" >> $peertube_config_file
|
echo " cache: 'cache/'";
|
||||||
echo '' >> $peertube_config_file
|
echo '';
|
||||||
echo 'cache:' >> $peertube_config_file
|
echo 'cache:';
|
||||||
echo ' previews:' >> $peertube_config_file
|
echo ' previews:';
|
||||||
echo ' size: 10 # Max number of previews you want to cache' >> $peertube_config_file
|
echo ' size: 10 # Max number of previews you want to cache';
|
||||||
echo '' >> $peertube_config_file
|
echo '';
|
||||||
echo 'admin:' >> $peertube_config_file
|
echo 'admin:';
|
||||||
# This is deliberately a dummy email address
|
# This is deliberately a dummy email address
|
||||||
echo " email: 'testuser@testdomain.net'" >> $peertube_config_file
|
echo " email: 'testuser@testdomain.net'";
|
||||||
echo '' >> $peertube_config_file
|
echo '';
|
||||||
echo 'signup:' >> $peertube_config_file
|
echo 'signup:';
|
||||||
echo ' enabled: true' >> $peertube_config_file
|
echo ' enabled: true';
|
||||||
echo ' limit: 5 # When the limit is reached, registrations are disabled. -1 == unlimited' >> $peertube_config_file
|
echo ' limit: 5 # When the limit is reached, registrations are disabled. -1 == unlimited';
|
||||||
echo '' >> $peertube_config_file
|
echo '';
|
||||||
echo 'user:' >> $peertube_config_file
|
echo 'user:';
|
||||||
echo ' # Default value of maximum video BYTES the user can upload (does not take into account transcoded files).' >> $peertube_config_file
|
echo ' # Default value of maximum video BYTES the user can upload (does not take into account transcoded files).';
|
||||||
echo ' # -1 == unlimited' >> $peertube_config_file
|
echo ' # -1 == unlimited';
|
||||||
echo ' video_quota: -1' >> $peertube_config_file
|
echo ' video_quota: -1';
|
||||||
echo '' >> $peertube_config_file
|
echo '';
|
||||||
echo '# If enabled, the video will be transcoded to mp4 (x264) with "faststart" flag' >> $peertube_config_file
|
echo '# If enabled, the video will be transcoded to mp4 (x264) with "faststart" flag';
|
||||||
echo '# Uses a lot of CPU!' >> $peertube_config_file
|
echo '# Uses a lot of CPU!';
|
||||||
echo 'transcoding:' >> $peertube_config_file
|
echo 'transcoding:';
|
||||||
echo ' enabled: true' >> $peertube_config_file
|
echo ' enabled: true';
|
||||||
echo ' threads: 2' >> $peertube_config_file
|
echo ' threads: 2';
|
||||||
echo ' resolutions: # Only created if the original video has a higher resolution' >> $peertube_config_file
|
echo ' resolutions: # Only created if the original video has a higher resolution';
|
||||||
echo ' 240p: true' >> $peertube_config_file
|
echo ' 240p: true';
|
||||||
echo ' 360p: false' >> $peertube_config_file
|
echo ' 360p: false';
|
||||||
echo ' 480p: false' >> $peertube_config_file
|
echo ' 480p: false';
|
||||||
echo ' 720p: false' >> $peertube_config_file
|
echo ' 720p: false';
|
||||||
echo ' 1080p: false' >> $peertube_config_file
|
echo ' 1080p: false'; } >> "$peertube_config_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mesh_install_peertube {
|
function mesh_install_peertube {
|
||||||
if [[ $VARIANT != "meshclient" && $VARIANT != "meshusb" ]]; then
|
if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ $ARCHITECTURE != 'x86_64' && $ARCHITECTURE != 'amd64' ]]; then
|
if [[ "$ARCHITECTURE" != 'x86_64' && "$ARCHITECTURE" != 'amd64' ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -627,22 +630,21 @@ function mesh_install_peertube {
|
||||||
function_check install_postgresql
|
function_check install_postgresql
|
||||||
install_postgresql
|
install_postgresql
|
||||||
|
|
||||||
if [ -d $rootdir$PEERTUBE_DIR ]; then
|
if [ -d "$rootdir$PEERTUBE_DIR" ]; then
|
||||||
rm -rf $rootdir$PEERTUBE_DIR
|
rm -rf "$rootdir$PEERTUBE_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git clone $PEERTUBE_REPO $rootdir$PEERTUBE_DIR
|
git clone "$PEERTUBE_REPO" "$rootdir$PEERTUBE_DIR"
|
||||||
|
|
||||||
chroot "$rootdir" groupadd peertube
|
chroot "$rootdir" groupadd peertube
|
||||||
chroot "$rootdir" useradd -c "PeerTube system account" -d $PEERTUBE_DIR -m -r -g peertube peertube
|
chroot "$rootdir" useradd -c "PeerTube system account" -d $PEERTUBE_DIR -m -r -g peertube peertube
|
||||||
|
|
||||||
cd $rootdir$PEERTUBE_DIR
|
cd "$rootdir$PEERTUBE_DIR" || exit 246824524
|
||||||
git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
|
git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
|
||||||
|
|
||||||
|
|
||||||
get_npm_arch
|
get_npm_arch
|
||||||
|
|
||||||
cat <<EOF > $rootdir/usr/bin/install_peertube
|
cat <<EOF > "$rootdir/usr/bin/install_peertube"
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd $PEERTUBE_DIR
|
cd $PEERTUBE_DIR
|
||||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
||||||
|
@ -683,34 +685,33 @@ if [ ! "\$?" = "0" ]; then
|
||||||
exit 5293593
|
exit 5293593
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
chmod +x $rootdir/usr/bin/install_peertube
|
chmod +x "$rootdir/usr/bin/install_peertube"
|
||||||
chroot "$rootdir" /usr/bin/install_peertube
|
if ! chroot "$rootdir" /usr/bin/install_peertube; then
|
||||||
if [ ! "$?" = "0" ]; then
|
|
||||||
echo $'PeerTube install failed'
|
echo $'PeerTube install failed'
|
||||||
exit 735638
|
exit 735638
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '[Unit]' > $rootdir/etc/systemd/system/peertube.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=PeerTube Decentralized video streaming platform' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'Description=PeerTube Decentralized video streaming platform';
|
||||||
echo 'After=syslog.target' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'After=syslog.target';
|
||||||
echo 'After=network.target' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'After=network.target';
|
||||||
echo '' >> $rootdir/etc/systemd/system/peertube.service
|
echo '';
|
||||||
echo '[Service]' >> $rootdir/etc/systemd/system/peertube.service
|
echo '[Service]';
|
||||||
echo 'User=peertube' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'User=peertube';
|
||||||
echo 'Group=peertube' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'Group=peertube';
|
||||||
echo "WorkingDirectory=$PEERTUBE_DIR" >> $rootdir/etc/systemd/system/peertube.service
|
echo "WorkingDirectory=$PEERTUBE_DIR";
|
||||||
echo "ExecStart=/usr/local/bin/npm start" >> $rootdir/etc/systemd/system/peertube.service
|
echo "ExecStart=/usr/local/bin/npm start";
|
||||||
echo "ExecStop=/usr/local/bin/npm stop" >> $rootdir/etc/systemd/system/peertube.service
|
echo "ExecStop=/usr/local/bin/npm stop";
|
||||||
echo 'StandardOutput=syslog' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'StandardOutput=syslog';
|
||||||
echo 'StandardError=syslog' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'StandardError=syslog';
|
||||||
echo 'SyslogIdentifier=peertube' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'SyslogIdentifier=peertube';
|
||||||
echo 'Restart=always' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'Restart=always';
|
||||||
echo "Environment=NODE_ENV=production" >> $rootdir/etc/systemd/system/peertube.service
|
echo "Environment=NODE_ENV=production";
|
||||||
echo '' >> $rootdir/etc/systemd/system/peertube.service
|
echo '';
|
||||||
echo '[Install]' >> $rootdir/etc/systemd/system/peertube.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/peertube.service
|
echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/peertube.service"
|
||||||
|
|
||||||
peertube_create_config $rootdir
|
peertube_create_config "$rootdir"
|
||||||
|
|
||||||
chroot "$rootdir" chown -R peertube:peertube $PEERTUBE_DIR
|
chroot "$rootdir" chown -R peertube:peertube $PEERTUBE_DIR
|
||||||
|
|
||||||
|
@ -730,7 +731,7 @@ function install_peertube {
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $PEERTUBE_DOMAIN_NAME ]; then
|
if [ ! "$PEERTUBE_DOMAIN_NAME" ]; then
|
||||||
echo $'The peertube domain name was not specified'
|
echo $'The peertube domain name was not specified'
|
||||||
exit 783523
|
exit 783523
|
||||||
fi
|
fi
|
||||||
|
@ -740,8 +741,8 @@ function install_peertube {
|
||||||
function_check install_postgresql
|
function_check install_postgresql
|
||||||
install_postgresql
|
install_postgresql
|
||||||
|
|
||||||
if [ ! -d /var/www/$PEERTUBE_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$PEERTUBE_DOMAIN_NAME/htdocs" ]; then
|
||||||
mkdir -p /var/www/$PEERTUBE_DOMAIN_NAME/htdocs
|
mkdir -p "/var/www/$PEERTUBE_DOMAIN_NAME/htdocs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $PEERTUBE_DIR ]; then
|
if [ -d $PEERTUBE_DIR ]; then
|
||||||
|
@ -759,60 +760,56 @@ function install_peertube {
|
||||||
if [ -d /repos/peertube ]; then
|
if [ -d /repos/peertube ]; then
|
||||||
mkdir -p $PEERTUBE_DIR
|
mkdir -p $PEERTUBE_DIR
|
||||||
cp -r -p /repos/peertube/. $PEERTUBE_DIR
|
cp -r -p /repos/peertube/. $PEERTUBE_DIR
|
||||||
cd $PEERTUBE_DIR
|
cd "$PEERTUBE_DIR" || exit 642874682
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
git_clone $PEERTUBE_REPO $PEERTUBE_DIR
|
git_clone $PEERTUBE_REPO $PEERTUBE_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $PEERTUBE_DIR
|
cd "$PEERTUBE_DIR" || exit 27492742
|
||||||
git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
|
git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
|
||||||
set_completion_param "peertube commit" "$PEERTUBE_COMMIT"
|
set_completion_param "peertube commit" "$PEERTUBE_COMMIT"
|
||||||
|
|
||||||
npm install -g yarn
|
if ! npm install -g yarn; then
|
||||||
if [ ! "$?" = "0" ]; then
|
|
||||||
echo $'Failed to install yarn'
|
echo $'Failed to install yarn'
|
||||||
exit 79353234
|
exit 79353234
|
||||||
fi
|
fi
|
||||||
yarn add -D webpack --network-concurrency 1
|
yarn add -D webpack --network-concurrency 1
|
||||||
yarn install
|
if ! yarn install; then
|
||||||
if [ ! "$?" = "0" ]; then
|
|
||||||
echo $'Failed to run yarn install'
|
echo $'Failed to run yarn install'
|
||||||
exit 63754235
|
exit 63754235
|
||||||
fi
|
fi
|
||||||
npm install
|
if ! npm install; then
|
||||||
if [ ! "$?" = "0" ]; then
|
|
||||||
echo $'Failed to install peertube'
|
echo $'Failed to install peertube'
|
||||||
exit 7835243
|
exit 7835243
|
||||||
fi
|
fi
|
||||||
npm run build
|
if ! npm run build; then
|
||||||
if [ ! "$?" = "0" ]; then
|
|
||||||
echo $'Failed to build peertube'
|
echo $'Failed to build peertube'
|
||||||
exit 5293593
|
exit 5293593
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT})
|
PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT})
|
||||||
|
|
||||||
echo '[Unit]' > /etc/systemd/system/peertube.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=PeerTube Decentralized video streaming platform' >> /etc/systemd/system/peertube.service
|
echo 'Description=PeerTube Decentralized video streaming platform';
|
||||||
echo 'After=syslog.target' >> /etc/systemd/system/peertube.service
|
echo 'After=syslog.target';
|
||||||
echo 'After=network.target' >> /etc/systemd/system/peertube.service
|
echo 'After=network.target';
|
||||||
echo '' >> /etc/systemd/system/peertube.service
|
echo '';
|
||||||
echo '[Service]' >> /etc/systemd/system/peertube.service
|
echo '[Service]';
|
||||||
echo 'User=peertube' >> /etc/systemd/system/peertube.service
|
echo 'User=peertube';
|
||||||
echo 'Group=peertube' >> /etc/systemd/system/peertube.service
|
echo 'Group=peertube';
|
||||||
echo "WorkingDirectory=$PEERTUBE_DIR" >> /etc/systemd/system/peertube.service
|
echo "WorkingDirectory=$PEERTUBE_DIR";
|
||||||
echo "ExecStart=/usr/local/bin/npm start" >> /etc/systemd/system/peertube.service
|
echo "ExecStart=/usr/local/bin/npm start";
|
||||||
echo "ExecStop=/usr/local/bin/npm stop" >> /etc/systemd/system/peertube.service
|
echo "ExecStop=/usr/local/bin/npm stop";
|
||||||
echo 'StandardOutput=syslog' >> /etc/systemd/system/peertube.service
|
echo 'StandardOutput=syslog';
|
||||||
echo 'StandardError=syslog' >> /etc/systemd/system/peertube.service
|
echo 'StandardError=syslog';
|
||||||
echo 'SyslogIdentifier=peertube' >> /etc/systemd/system/peertube.service
|
echo 'SyslogIdentifier=peertube';
|
||||||
echo 'Restart=always' >> /etc/systemd/system/peertube.service
|
echo 'Restart=always';
|
||||||
echo "Environment=NODE_ENV=production" >> /etc/systemd/system/peertube.service
|
echo "Environment=NODE_ENV=production";
|
||||||
echo '' >> /etc/systemd/system/peertube.service
|
echo '';
|
||||||
echo '[Install]' >> /etc/systemd/system/peertube.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/peertube.service
|
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/peertube.service
|
||||||
|
|
||||||
peertube_create_config
|
peertube_create_config
|
||||||
|
|
||||||
|
@ -820,10 +817,10 @@ function install_peertube {
|
||||||
|
|
||||||
peertube_setup_web
|
peertube_setup_web
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a peertube -p "$PEERTUBE_ADMIN_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a peertube -p "$PEERTUBE_ADMIN_PASSWORD"
|
||||||
|
|
||||||
function_check add_ddns_domain
|
function_check add_ddns_domain
|
||||||
add_ddns_domain $PEERTUBE_DOMAIN_NAME
|
add_ddns_domain "$PEERTUBE_DOMAIN_NAME"
|
||||||
|
|
||||||
systemctl enable peertube
|
systemctl enable peertube
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
|
@ -50,12 +50,12 @@ pelican_variables=(MY_USERNAME
|
||||||
PELICAN_BLOG_CODE)
|
PELICAN_BLOG_CODE)
|
||||||
|
|
||||||
function pelican_remove_bad_blog_links {
|
function pelican_remove_bad_blog_links {
|
||||||
find ./ -type f -name *.css -exec sed -i -e '/googleapi/d' {} \;
|
find ./ -type f -name "*.css" -exec sed -i -e '/googleapi/d' {} \;
|
||||||
find ./ -type f -name *.scss -exec sed -i -e '/googleapi/d' {} \;
|
find ./ -type f -name "*.scss" -exec sed -i -e '/googleapi/d' {} \;
|
||||||
find ./ -type f -name *.html -exec sed -i -e '/googleapi/d' {} \;
|
find ./ -type f -name "*.html" -exec sed -i -e '/googleapi/d' {} \;
|
||||||
find ./ -type f -name *.css -exec sed -i -e '/bootstrapcdn/d' {} \;
|
find ./ -type f -name "*.css" -exec sed -i -e '/bootstrapcdn/d' {} \;
|
||||||
find ./ -type f -name *.scss -exec sed -i -e '/bootstrapcdn/d' {} \;
|
find ./ -type f -name "*.scss" -exec sed -i -e '/bootstrapcdn/d' {} \;
|
||||||
find ./ -type f -name *.html -exec sed -i -e '/bootstrapcdn/d' {} \;
|
find ./ -type f -name "*.html" -exec sed -i -e '/bootstrapcdn/d' {} \;
|
||||||
}
|
}
|
||||||
|
|
||||||
function logging_on_pelican {
|
function logging_on_pelican {
|
||||||
|
@ -73,104 +73,104 @@ function install_pelican_website {
|
||||||
fi
|
fi
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $PELICAN_DOMAIN_NAME
|
nginx_http_redirect $PELICAN_DOMAIN_NAME
|
||||||
echo 'server {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo " root /var/www/${PELICAN_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo " root /var/www/${PELICAN_DOMAIN_NAME}/htdocs;";
|
||||||
echo " server_name ${PELICAN_DOMAIN_NAME};" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo " server_name ${PELICAN_DOMAIN_NAME};";
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' access_log /dev/null;';
|
||||||
echo " error_log /dev/null;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo " error_log /dev/null;";
|
||||||
echo ' index index.html;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' index index.html;';
|
||||||
echo ' charset utf-8;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' charset utf-8;'; } >> "/etc/nginx/sites-available/$PELICAN_DOMAIN_NAME"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $PELICAN_DOMAIN_NAME
|
nginx_ssl "$PELICAN_DOMAIN_NAME"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $PELICAN_DOMAIN_NAME
|
nginx_disable_sniffing "$PELICAN_DOMAIN_NAME"
|
||||||
echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
{ echo ' add_header Strict-Transport-Security "max-age=0;";';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location / {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location / {'; } >> "/etc/nginx/sites-available/$PELICAN_DOMAIN_NAME"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $PELICAN_DOMAIN_NAME
|
nginx_limits "$PELICAN_DOMAIN_NAME"
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
{ echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' # block these file types' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' # block these file types';
|
||||||
echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~* \.(tpl|md|tgz|log|out)$ {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' # deny access to all dot files';
|
||||||
echo ' location ~ /\. {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~ /\. {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~ /(data|conf|bin|inc)/ {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~ /\.ht {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '}' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '}';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ''; } >> "/etc/nginx/sites-available/$PELICAN_DOMAIN_NAME"
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate $PELICAN_DOMAIN_NAME 'yes'
|
create_site_certificate "$PELICAN_DOMAIN_NAME" 'yes'
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_pelican_website_onion {
|
function install_pelican_website_onion {
|
||||||
echo 'server {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:${PELICAN_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo " listen 127.0.0.1:${PELICAN_ONION_PORT} default_server;";
|
||||||
echo " root /var/www/${PELICAN_DOMAIN_NAME}/htdocs;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo " root /var/www/${PELICAN_DOMAIN_NAME}/htdocs;";
|
||||||
echo " server_name ${PELICAN_DOMAIN_NAME};" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo " server_name ${PELICAN_DOMAIN_NAME};";
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' access_log /dev/null;';
|
||||||
echo " error_log /dev/null;" >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo " error_log /dev/null;";
|
||||||
echo ' index index.html;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' index index.html;';
|
||||||
echo ' charset utf-8;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' charset utf-8;'; } >> "/etc/nginx/sites-available/$PELICAN_DOMAIN_NAME"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $PELICAN_DOMAIN_NAME
|
nginx_disable_sniffing "$PELICAN_DOMAIN_NAME"
|
||||||
echo ' add_header Strict-Transport-Security "max-age=0;";' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
{ echo ' add_header Strict-Transport-Security "max-age=0;";';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location / {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location / {'; } >> "/etc/nginx/sites-available/$PELICAN_DOMAIN_NAME"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $PELICAN_DOMAIN_NAME
|
nginx_limits "$PELICAN_DOMAIN_NAME"
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
{ echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' # block these file types' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' # block these file types';
|
||||||
echo ' location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~* \.(tpl|md|tgz|log|out)$ {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' # deny access to all dot files' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' # deny access to all dot files';
|
||||||
echo ' location ~ /\. {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~ /\. {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location ~ /(data|conf|bin|inc)/ {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~ /(data|conf|bin|inc)/ {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo ' location ~ /\.ht {' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' location ~ /\.ht {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '}' >> /etc/nginx/sites-available/$PELICAN_DOMAIN_NAME
|
echo '}'; } >> "/etc/nginx/sites-available/$PELICAN_DOMAIN_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function pelican_editor_config {
|
function pelican_editor_config {
|
||||||
if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican ]; then
|
if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican ]; then
|
||||||
echo "(add-hook 'before-save-hook 'delete-trailing-whitespace)" > $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
{ echo "(add-hook 'before-save-hook 'delete-trailing-whitespace)";
|
||||||
echo '(setq org-support-shift-select t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq org-support-shift-select t)';
|
||||||
echo '(setq standard-indent 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq standard-indent 4)';
|
||||||
echo '(setq-default tab-width 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq-default tab-width 4)';
|
||||||
echo '(setq c-basic-offset 4)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq c-basic-offset 4)';
|
||||||
echo '(mouse-wheel-mode t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(mouse-wheel-mode t)';
|
||||||
echo '(setq make-backup-files t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq make-backup-files t)';
|
||||||
echo '(setq version-control t)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq version-control t)';
|
||||||
echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))';
|
||||||
echo "(setq default-major-mode 'text-mode)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo "(setq default-major-mode 'text-mode)";
|
||||||
echo "(dolist (hook '(text-mode-hook))" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo "(dolist (hook '(text-mode-hook))";
|
||||||
echo ' (add-hook hook (lambda () (flyspell-mode 1))))' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo ' (add-hook hook (lambda () (flyspell-mode 1))))';
|
||||||
echo '(setq-default fill-column 72)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq-default fill-column 72)';
|
||||||
echo '(setq auto-fill-mode 0)' >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo '(setq auto-fill-mode 0)';
|
||||||
echo "(add-hook 'text-mode-hook 'turn-on-auto-fill)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo "(add-hook 'text-mode-hook 'turn-on-auto-fill)";
|
||||||
echo "(setq-default auto-fill-function 'do-auto-fill)" >> $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican
|
echo "(setq-default auto-fill-function 'do-auto-fill)"; } > "$PELICAN_BLOG_INSTALL_DIR/.emacs-pelican"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ function pelican_regenerate_blog {
|
||||||
echo ''
|
echo ''
|
||||||
echo $'Regenerating blog...'
|
echo $'Regenerating blog...'
|
||||||
|
|
||||||
cd $PELICAN_BLOG_INSTALL_DIR
|
cd "$PELICAN_BLOG_INSTALL_DIR" || exit 463856348
|
||||||
make html
|
make html
|
||||||
cp -r $PELICAN_BLOG_INSTALL_DIR/output/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
|
cp -r $PELICAN_BLOG_INSTALL_DIR/output/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
|
||||||
chown -R www-data:www-data /var/www/$PELICAN_DOMAIN_NAME/htdocs
|
chown -R www-data:www-data /var/www/$PELICAN_DOMAIN_NAME/htdocs
|
||||||
|
@ -189,19 +189,19 @@ function pelican_new_blog {
|
||||||
DATESTR=$(date "+%Y-%m-%d %H:%M:%S")
|
DATESTR=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry ]; then
|
if [ ! -f $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry ]; then
|
||||||
echo $'Title: Blog Post Title' > $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
{ echo $'Title: Blog Post Title';
|
||||||
echo $"Date: ${DATESTR}" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo $"Date: ${DATESTR}";
|
||||||
echo $"Author: $(toxid --showuser)" >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo $"Author: $(toxid --showuser)";
|
||||||
echo $'Category: default' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo $'Category: default';
|
||||||
echo $'Tags: blog, tag' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo $'Tags: blog, tag';
|
||||||
echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo '';
|
||||||
echo $'Add your text here' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo $'Add your text here';
|
||||||
echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo '';
|
||||||
echo -n $'To include an image copy it into the /etc/blog/content/images directory, ' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo -n $'To include an image copy it into the /etc/blog/content/images directory, ';
|
||||||
echo $'then link to it with:' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo $'then link to it with:';
|
||||||
echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo '';
|
||||||
echo $'![My image]({filename}images/myimage.jpg)' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo $'![My image]({filename}images/myimage.jpg)';
|
||||||
echo '' >> $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
echo ''; } > $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /usr/bin/emacs ]; then
|
if [ -f /usr/bin/emacs ]; then
|
||||||
|
@ -222,7 +222,7 @@ function pelican_new_blog {
|
||||||
|
|
||||||
# move to the content directory
|
# move to the content directory
|
||||||
CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
|
CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
|
||||||
mv $PELICAN_BLOG_INSTALL_DIR/.new-blog-entry $BLOG_CONTENT_PATH/${CURRENT_INDEX}_post.md
|
mv "$PELICAN_BLOG_INSTALL_DIR/.new-blog-entry" "$BLOG_CONTENT_PATH/${CURRENT_INDEX}_post.md"
|
||||||
|
|
||||||
# increment the index
|
# increment the index
|
||||||
CURRENT_INDEX=$((CURRENT_INDEX + 1))
|
CURRENT_INDEX=$((CURRENT_INDEX + 1))
|
||||||
|
@ -238,14 +238,14 @@ function pelican_edit_blog {
|
||||||
CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
|
CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
|
||||||
PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
|
PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
|
||||||
LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
|
LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
|
||||||
if [ ! -f $LAST_BLOG_ENTRY ]; then
|
if [ ! -f "$LAST_BLOG_ENTRY" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /usr/bin/emacs ]; then
|
if [ -f /usr/bin/emacs ]; then
|
||||||
emacs -q --load $PELICAN_BLOG_INSTALL_DIR/.emacs-pelican $LAST_BLOG_ENTRY
|
emacs -q --load "$PELICAN_BLOG_INSTALL_DIR/.emacs-pelican" "$LAST_BLOG_ENTRY"
|
||||||
else
|
else
|
||||||
editor $LAST_BLOG_ENTRY
|
editor "$LAST_BLOG_ENTRY"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pelican_regenerate_blog
|
pelican_regenerate_blog
|
||||||
|
@ -258,18 +258,18 @@ function pelican_delete_blog {
|
||||||
CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
|
CURRENT_INDEX=$(cat $PELICAN_CURRENT_BLOG_INDEX)
|
||||||
PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
|
PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
|
||||||
LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
|
LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.md
|
||||||
if [ ! -f $LAST_BLOG_ENTRY ]; then
|
if [ ! -f "$LAST_BLOG_ENTRY" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dialog --title $"Delete the previous blog entry" \
|
dialog --title $"Delete the previous blog entry" \
|
||||||
--backtitle $"Freedombone Mesh" \
|
--backtitle $"Freedombone Mesh" \
|
||||||
--defaultno \
|
--defaultno \
|
||||||
--yesno $"\nAre you sure that you wish to delete the previous blog entry?" 8 60
|
--yesno $"\\nAre you sure that you wish to delete the previous blog entry?" 8 60
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
0) rm $LAST_BLOG_ENTRY
|
0) rm "$LAST_BLOG_ENTRY"
|
||||||
if [ $CURRENT_INDEX -gt 0 ]; then
|
if [ "$CURRENT_INDEX" -gt 0 ]; then
|
||||||
CURRENT_INDEX=$PREVIOUS_INDEX
|
CURRENT_INDEX=$PREVIOUS_INDEX
|
||||||
echo "$CURRENT_INDEX" > $PELICAN_CURRENT_BLOG_INDEX
|
echo "$CURRENT_INDEX" > $PELICAN_CURRENT_BLOG_INDEX
|
||||||
else
|
else
|
||||||
|
@ -297,8 +297,8 @@ function pelican_change_theme {
|
||||||
for a in "${THEMES[@]}"
|
for a in "${THEMES[@]}"
|
||||||
do
|
do
|
||||||
is_selected='off'
|
is_selected='off'
|
||||||
if [ $curr_theme_index ]; then
|
if [ "$curr_theme_index" ]; then
|
||||||
if [ $n -eq $curr_theme_index ]; then
|
if [ $n -eq "$curr_theme_index" ]; then
|
||||||
is_selected='on'
|
is_selected='on'
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -308,28 +308,30 @@ function pelican_change_theme {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
themelist="$themelist $n $a $is_selected"
|
themelist="$themelist $n $a $is_selected"
|
||||||
n=$[n+1]
|
n=$((n+1))
|
||||||
theme_index=$[theme_index+1]
|
theme_index=$((theme_index+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Mesh" \
|
dialog --backtitle $"Freedombone Mesh" \
|
||||||
--title $"Select Blog Theme" \
|
--title $"Select Blog Theme" \
|
||||||
--radiolist $'Choose:' \
|
--radiolist $'Choose:' \
|
||||||
80 40 20 $themelist 2> $data
|
80 40 20 "$themelist" 2> "$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) return;;
|
1) rm -f "$data"
|
||||||
255) return;;
|
return;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
return;;
|
||||||
esac
|
esac
|
||||||
CHOSEN_THEME_INDEX=$(cat $data)
|
CHOSEN_THEME_INDEX=$(cat "$data")
|
||||||
|
rm -f "$data"
|
||||||
echo "$CHOSEN_THEME_INDEX" > $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index
|
echo "$CHOSEN_THEME_INDEX" > $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index
|
||||||
CHOSEN_THEME_INDEX=$((CHOSEN_THEME_INDEX - 1))
|
CHOSEN_THEME_INDEX=$((CHOSEN_THEME_INDEX - 1))
|
||||||
|
|
||||||
CHOSEN_THEME=${THEMES[$CHOSEN_THEME_INDEX]}
|
CHOSEN_THEME=${THEMES[$CHOSEN_THEME_INDEX]}
|
||||||
|
|
||||||
cd $PELICAN_BLOG_INSTALL_DIR/themes/$CHOSEN_THEME
|
cd "$PELICAN_BLOG_INSTALL_DIR/themes/$CHOSEN_THEME" || exit 2648268284
|
||||||
pelican_remove_bad_blog_links
|
pelican_remove_bad_blog_links
|
||||||
|
|
||||||
if grep -q "THEME=" $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py; then
|
if grep -q "THEME=" $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py; then
|
||||||
|
@ -341,8 +343,7 @@ function pelican_change_theme {
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_interactive_pelican {
|
function configure_interactive_pelican {
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"Pelican Blogging" \
|
--title $"Pelican Blogging" \
|
||||||
--radiolist $"Choose an operation:" 18 50 11 \
|
--radiolist $"Choose an operation:" 18 50 11 \
|
||||||
|
@ -350,23 +351,25 @@ function configure_interactive_pelican {
|
||||||
2 $"Edit the previous blog entry" off \
|
2 $"Edit the previous blog entry" off \
|
||||||
3 $"Delete the previous blog entry" off \
|
3 $"Delete the previous blog entry" off \
|
||||||
4 $"Change theme" off \
|
4 $"Change theme" off \
|
||||||
5 $"Exit" off 2> $data
|
5 $"Exit" off 2> "$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) return;;
|
1) rm -f "$data"
|
||||||
255) return;;
|
return;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
return;;
|
||||||
esac
|
esac
|
||||||
case $(cat $data) in
|
case $(cat "$data") in
|
||||||
1) pelican_new_blog;;
|
1) pelican_new_blog;;
|
||||||
2) pelican_edit_blog;;
|
2) pelican_edit_blog;;
|
||||||
3) pelican_delete_blog;;
|
3) pelican_delete_blog;;
|
||||||
4) pelican_change_theme;;
|
4) pelican_change_theme;;
|
||||||
5) break;;
|
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_interactive_pelican {
|
function install_interactive_pelican {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -376,42 +379,43 @@ function install_interactive_pelican {
|
||||||
PELICAN_DETAILS_COMPLETE=
|
PELICAN_DETAILS_COMPLETE=
|
||||||
while [ ! $PELICAN_DETAILS_COMPLETE ]
|
while [ ! $PELICAN_DETAILS_COMPLETE ]
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"Pelican Blog Configuration" \
|
--title $"Pelican Blog Configuration" \
|
||||||
--form $"\nPlease enter your blog details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
--form $"\\nPlease enter your blog details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'PELICAN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
$"Domain:" 1 1 "$(grep 'PELICAN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||||
$"Code:" 2 1 "$(grep 'PELICAN_BLOG_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
|
$"Code:" 2 1 "$(grep 'PELICAN_BLOG_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
|
||||||
2> $data
|
2> "$data"
|
||||||
else
|
else
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"Pelican Blog Configuration" \
|
--title $"Pelican Blog Configuration" \
|
||||||
--form $"\nPlease enter your GNU Social details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
--form $"\\nPlease enter your GNU Social details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'PELICAN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
$"Domain:" 1 1 "$(grep 'PELICAN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||||
2> $data
|
2> "$data"
|
||||||
fi
|
fi
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) rm -f "$data"
|
||||||
255) exit 1;;
|
exit 1;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
PELICAN_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
PELICAN_DOMAIN_NAME=$(sed -n 1p < "$data")
|
||||||
if [ $PELICAN_DOMAIN_NAME ]; then
|
if [ "$PELICAN_DOMAIN_NAME" ]; then
|
||||||
if [[ $PELICAN_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
if [[ $PELICAN_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
||||||
PELICAN_DOMAIN_NAME=""
|
PELICAN_DOMAIN_NAME=""
|
||||||
fi
|
fi
|
||||||
TEST_DOMAIN_NAME=$PELICAN_DOMAIN_NAME
|
TEST_DOMAIN_NAME=$PELICAN_DOMAIN_NAME
|
||||||
validate_domain_name
|
validate_domain_name
|
||||||
if [[ $TEST_DOMAIN_NAME != $PELICAN_DOMAIN_NAME ]]; then
|
if [[ "$TEST_DOMAIN_NAME" != "$PELICAN_DOMAIN_NAME" ]]; then
|
||||||
PELICAN_DOMAIN_NAME=
|
PELICAN_DOMAIN_NAME=
|
||||||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||||||
else
|
else
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
PELICAN_BLOG_CODE=$(cat $data | sed -n 2p)
|
PELICAN_BLOG_CODE=$(sed -n 2p < "$data")
|
||||||
validate_freedns_code "$PELICAN_BLOG_CODE"
|
validate_freedns_code "$PELICAN_BLOG_CODE"
|
||||||
if [ ! $VALID_CODE ]; then
|
if [ ! "$VALID_CODE" ]; then
|
||||||
PELICAN_DOMAIN_NAME=
|
PELICAN_DOMAIN_NAME=
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -420,6 +424,7 @@ function install_interactive_pelican {
|
||||||
if [ $PELICAN_DOMAIN_NAME ]; then
|
if [ $PELICAN_DOMAIN_NAME ]; then
|
||||||
PELICAN_DETAILS_COMPLETE="yes"
|
PELICAN_DETAILS_COMPLETE="yes"
|
||||||
fi
|
fi
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
|
|
||||||
# save the results in the config file
|
# save the results in the config file
|
||||||
|
@ -454,7 +459,7 @@ function backup_local_pelican {
|
||||||
|
|
||||||
function restore_local_pelican {
|
function restore_local_pelican {
|
||||||
if [ -d /etc/blog ]; then
|
if [ -d /etc/blog ]; then
|
||||||
if [ -d $USB_MOUNT_DLNA/backup/pelican ]; then
|
if [ -d "$USB_MOUNT_DLNA/backup/pelican" ]; then
|
||||||
temp_restore_dir=/root/temppelican
|
temp_restore_dir=/root/temppelican
|
||||||
function_check restore_directory_from_usb
|
function_check restore_directory_from_usb
|
||||||
restore_directory_from_usb $temp_restore_dir pelican
|
restore_directory_from_usb $temp_restore_dir pelican
|
||||||
|
@ -463,6 +468,7 @@ function restore_local_pelican {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /etc/blog/
|
cp -r $temp_restore_dir/* /etc/blog/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
function_check set_user_permissions
|
function_check set_user_permissions
|
||||||
|
@ -475,7 +481,7 @@ function restore_local_pelican {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -d /var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
|
if [ -d /var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
|
||||||
if [ -d $USB_MOUNT_DLNA/backup/pelican-site ]; then
|
if [ -d "$USB_MOUNT_DLNA/backup/pelican-site" ]; then
|
||||||
temp_restore_dir=/root/temppelican-site
|
temp_restore_dir=/root/temppelican-site
|
||||||
function_check restore_directory_from_usb
|
function_check restore_directory_from_usb
|
||||||
restore_directory_from_usb $temp_restore_dir pelican-site
|
restore_directory_from_usb $temp_restore_dir pelican-site
|
||||||
|
@ -484,6 +490,7 @@ function restore_local_pelican {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
|
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
function_check set_user_permissions
|
function_check set_user_permissions
|
||||||
|
@ -508,7 +515,7 @@ function backup_remote_pelican {
|
||||||
|
|
||||||
function restore_remote_pelican {
|
function restore_remote_pelican {
|
||||||
if [ -d /etc/blog ]; then
|
if [ -d /etc/blog ]; then
|
||||||
if [ -d $SERVER_DIRECTORY/backup/pelican ]; then
|
if [ -d "$SERVER_DIRECTORY/backup/pelican" ]; then
|
||||||
temp_restore_dir=/root/temppelican
|
temp_restore_dir=/root/temppelican
|
||||||
function_check restore_directory_from_friend
|
function_check restore_directory_from_friend
|
||||||
restore_directory_from_friend $temp_restore_dir pelican
|
restore_directory_from_friend $temp_restore_dir pelican
|
||||||
|
@ -517,6 +524,7 @@ function restore_remote_pelican {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /etc/blog/
|
cp -r $temp_restore_dir/* /etc/blog/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 782352
|
exit 782352
|
||||||
fi
|
fi
|
||||||
|
@ -524,7 +532,7 @@ function restore_remote_pelican {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -d /var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
|
if [ -d /var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
|
||||||
if [ -d $SERVER_DIRECTORY/backup/pelican-site ]; then
|
if [ -d "$SERVER_DIRECTORY/backup/pelican-site" ]; then
|
||||||
temp_restore_dir=/root/temppelican-site
|
temp_restore_dir=/root/temppelican-site
|
||||||
function_check restore_directory_from_friend
|
function_check restore_directory_from_friend
|
||||||
restore_directory_from_friend $temp_restore_dir pelican-site
|
restore_directory_from_friend $temp_restore_dir pelican-site
|
||||||
|
@ -533,6 +541,7 @@ function restore_remote_pelican {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
|
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 76382562
|
exit 76382562
|
||||||
fi
|
fi
|
||||||
|
@ -561,112 +570,112 @@ function remove_pelican {
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_pelican_conf {
|
function create_pelican_conf {
|
||||||
STATIC_BLOG_FILE=$1
|
STATIC_BLOG_FILE="$1"
|
||||||
|
|
||||||
echo '#!/usr/bin/env python' > $STATIC_BLOG_FILE
|
{ echo '#!/usr/bin/env python';
|
||||||
echo '# -*- coding: utf-8 -*- #' >> $STATIC_BLOG_FILE
|
echo '# -*- coding: utf-8 -*- #';
|
||||||
echo 'from __future__ import unicode_literals' >> $STATIC_BLOG_FILE
|
echo 'from __future__ import unicode_literals';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo "AUTHOR=u\"$MY_USERNAME\"" >> $STATIC_BLOG_FILE
|
echo "AUTHOR=u\"$MY_USERNAME\"";
|
||||||
echo "SITENAME=u'$DEFAULT_BLOG_TITLE'" >> $STATIC_BLOG_FILE
|
echo "SITENAME=u'$DEFAULT_BLOG_TITLE'";
|
||||||
echo "SITEURL=''" >> $STATIC_BLOG_FILE
|
echo "SITEURL=''";
|
||||||
echo "PATH='content'" >> $STATIC_BLOG_FILE
|
echo "PATH='content'";
|
||||||
echo 'TIMEZONE=u"Europe/London"' >> $STATIC_BLOG_FILE
|
echo 'TIMEZONE=u"Europe/London"';
|
||||||
echo "DEFAULT_LANG=u'en'" >> $STATIC_BLOG_FILE
|
echo "DEFAULT_LANG=u'en'";
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'FEED_ALL_ATOM=None' >> $STATIC_BLOG_FILE
|
echo 'FEED_ALL_ATOM=None';
|
||||||
echo 'CATEGORY_FEED_ATOM=None' >> $STATIC_BLOG_FILE
|
echo 'CATEGORY_FEED_ATOM=None';
|
||||||
echo 'TRANSLATION_FEED_ATOM=None' >> $STATIC_BLOG_FILE
|
echo 'TRANSLATION_FEED_ATOM=None';
|
||||||
echo 'AUTHOR_FEED_ATOM=None' >> $STATIC_BLOG_FILE
|
echo 'AUTHOR_FEED_ATOM=None';
|
||||||
echo 'AUTHOR_FEED_RSS=None' >> $STATIC_BLOG_FILE
|
echo 'AUTHOR_FEED_RSS=None';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'DEFAULT_PAGINATION=False' >> $STATIC_BLOG_FILE
|
echo 'DEFAULT_PAGINATION=False';
|
||||||
echo 'RELATIVE_URLS=True' >> $STATIC_BLOG_FILE
|
echo 'RELATIVE_URLS=True';
|
||||||
echo "THEME='themes/nice-blog'" >> $STATIC_BLOG_FILE
|
echo "THEME='themes/nice-blog'"; } > "$STATIC_BLOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_pelican_makefile {
|
function create_pelican_makefile {
|
||||||
STATIC_BLOG_FILE=$1
|
STATIC_BLOG_FILE="$1"
|
||||||
|
|
||||||
echo 'PY?=python' > $STATIC_BLOG_FILE
|
{ echo 'PY?=python';
|
||||||
echo 'PELICAN?=pelican' >> $STATIC_BLOG_FILE
|
echo 'PELICAN?=pelican';
|
||||||
echo 'PELICANOPTS=' >> $STATIC_BLOG_FILE
|
echo 'PELICANOPTS=';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'BASEDIR=$(CURDIR)' >> $STATIC_BLOG_FILE
|
echo "BASEDIR=\$(CURDIR)";
|
||||||
echo 'INPUTDIR=$(BASEDIR)/content' >> $STATIC_BLOG_FILE
|
echo "INPUTDIR=\$(BASEDIR)/content";
|
||||||
echo "OUTPUTDIR=$PELICAN_BLOG_PATH" >> $STATIC_BLOG_FILE
|
echo "OUTPUTDIR=$PELICAN_BLOG_PATH";
|
||||||
echo 'CONFFILE=$(BASEDIR)/pelicanconf.py' >> $STATIC_BLOG_FILE
|
echo "CONFFILE=\$(BASEDIR)/pelicanconf.py";
|
||||||
echo 'PUBLISHCONF=$(BASEDIR)/publishconf.py' >> $STATIC_BLOG_FILE
|
echo "PUBLISHCONF=\$(BASEDIR)/publishconf.py";
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'DEBUG ?= 0' >> $STATIC_BLOG_FILE
|
echo 'DEBUG ?= 0';
|
||||||
echo 'ifeq ($(DEBUG), 1)' >> $STATIC_BLOG_FILE
|
echo "ifeq (\$(DEBUG), 1)";
|
||||||
echo -e '\tPELICANOPTS += -D' >> $STATIC_BLOG_FILE
|
echo -e '\tPELICANOPTS += -D';
|
||||||
echo 'endif' >> $STATIC_BLOG_FILE
|
echo 'endif';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'RELATIVE ?= 0' >> $STATIC_BLOG_FILE
|
echo 'RELATIVE ?= 0';
|
||||||
echo 'ifeq ($(RELATIVE), 1)' >> $STATIC_BLOG_FILE
|
echo "ifeq (\$(RELATIVE), 1)";
|
||||||
echo -e '\tPELICANOPTS += --relative-urls' >> $STATIC_BLOG_FILE
|
echo -e '\tPELICANOPTS += --relative-urls';
|
||||||
echo 'endif' >> $STATIC_BLOG_FILE
|
echo 'endif';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'html:' >> $STATIC_BLOG_FILE
|
echo 'html:';
|
||||||
echo -e '\t$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)' >> $STATIC_BLOG_FILE
|
echo -e "\\t\$(PELICAN) \$(INPUTDIR) -o \$(OUTPUTDIR) -s \$(CONFFILE) \$(PELICANOPTS)";
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'clean:' >> $STATIC_BLOG_FILE
|
echo 'clean:';
|
||||||
echo -e '\t[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)' >> $STATIC_BLOG_FILE
|
echo -e "\\t[ ! -d \$(OUTPUTDIR) ] || rm -rf \$(OUTPUTDIR)";
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'regenerate:' >> $STATIC_BLOG_FILE
|
echo 'regenerate:';
|
||||||
echo -e '\t$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)' >> $STATIC_BLOG_FILE
|
echo -e "\\t\$(PELICAN) -r \$(INPUTDIR) -o \$(OUTPUTDIR) -s \$(CONFFILE) \$(PELICANOPTS)";
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'serve:' >> $STATIC_BLOG_FILE
|
echo 'serve:';
|
||||||
echo 'ifdef PORT' >> $STATIC_BLOG_FILE
|
echo 'ifdef PORT';
|
||||||
echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)' >> $STATIC_BLOG_FILE
|
echo -e "\\tcd \$(OUTPUTDIR) && \$(PY) -m pelican.server \$(PORT)";
|
||||||
echo 'else' >> $STATIC_BLOG_FILE
|
echo 'else';
|
||||||
echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server' >> $STATIC_BLOG_FILE
|
echo -e "\\tcd \$(OUTPUTDIR) && \$(PY) -m pelican.server";
|
||||||
echo 'endif' >> $STATIC_BLOG_FILE
|
echo 'endif';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'serve-global:' >> $STATIC_BLOG_FILE
|
echo 'serve-global:';
|
||||||
echo 'ifdef SERVER' >> $STATIC_BLOG_FILE
|
echo 'ifdef SERVER';
|
||||||
echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server 80 $(SERVER)' >> $STATIC_BLOG_FILE
|
echo -e "\\tcd \$(OUTPUTDIR) && \$(PY) -m pelican.server 80 \$(SERVER)";
|
||||||
echo 'else' >> $STATIC_BLOG_FILE
|
echo 'else';
|
||||||
echo -e '\tcd $(OUTPUTDIR) && $(PY) -m pelican.server 80 0.0.0.0' >> $STATIC_BLOG_FILE
|
echo -e "\\tcd \$(OUTPUTDIR) && \$(PY) -m pelican.server 80 0.0.0.0";
|
||||||
echo 'endif' >> $STATIC_BLOG_FILE
|
echo 'endif';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'devserver:' >> $STATIC_BLOG_FILE
|
echo 'devserver:';
|
||||||
echo 'ifdef PORT' >> $STATIC_BLOG_FILE
|
echo 'ifdef PORT';
|
||||||
echo -e '\t$(BASEDIR)/develop_server.sh restart $(PORT)' >> $STATIC_BLOG_FILE
|
echo -e "\\t\$(BASEDIR)/develop_server.sh restart \$(PORT)";
|
||||||
echo 'else' >> $STATIC_BLOG_FILE
|
echo 'else';
|
||||||
echo -e '\t$(BASEDIR)/develop_server.sh restart' >> $STATIC_BLOG_FILE
|
echo -e "\\t\$(BASEDIR)/develop_server.sh restart";
|
||||||
echo 'endif' >> $STATIC_BLOG_FILE
|
echo 'endif';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'stopserver:' >> $STATIC_BLOG_FILE
|
echo 'stopserver:';
|
||||||
echo -e '\t$(BASEDIR)/develop_server.sh stop' >> $STATIC_BLOG_FILE
|
echo -e "\\t\$(BASEDIR)/develop_server.sh stop";
|
||||||
echo -e '\t@echo "Stopped Pelican and SimpleHTTPServer processes running in background."' >> $STATIC_BLOG_FILE
|
echo -e '\t@echo "Stopped Pelican and SimpleHTTPServer processes running in background."';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'publish:' >> $STATIC_BLOG_FILE
|
echo 'publish:';
|
||||||
echo -e '\t$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)' >> $STATIC_BLOG_FILE
|
echo -e "\\t\$(PELICAN) \$(INPUTDIR) -o \$(OUTPUTDIR) -s \$(PUBLISHCONF) \$(PELICANOPTS)";
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo '.PHONY: html clean regenerate serve serve-global devserver publish' >> $STATIC_BLOG_FILE
|
echo '.PHONY: html clean regenerate serve serve-global devserver publish'; } > "$STATIC_BLOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_pelican_publish_conf {
|
function create_pelican_publish_conf {
|
||||||
STATIC_BLOG_FILE=$1
|
STATIC_BLOG_FILE=$1
|
||||||
|
|
||||||
echo '#!/usr/bin/env python' > $STATIC_BLOG_FILE
|
{ echo '#!/usr/bin/env python';
|
||||||
echo '# -*- coding: utf-8 -*- #' >> $STATIC_BLOG_FILE
|
echo '# -*- coding: utf-8 -*- #';
|
||||||
echo 'from __future__ import unicode_literals' >> $STATIC_BLOG_FILE
|
echo 'from __future__ import unicode_literals';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'import os' >> $STATIC_BLOG_FILE
|
echo 'import os';
|
||||||
echo 'import sys' >> $STATIC_BLOG_FILE
|
echo 'import sys';
|
||||||
echo 'sys.path.append(os.curdir)' >> $STATIC_BLOG_FILE
|
echo 'sys.path.append(os.curdir)';
|
||||||
echo 'from pelicanconf import *' >> $STATIC_BLOG_FILE
|
echo 'from pelicanconf import *';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo "SITEURL = ''" >> $STATIC_BLOG_FILE
|
echo "SITEURL = ''";
|
||||||
echo 'RELATIVE_URLS = True' >> $STATIC_BLOG_FILE
|
echo 'RELATIVE_URLS = True';
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo "FEED_ALL_ATOM = 'feeds/all.atom.xml'" >> $STATIC_BLOG_FILE
|
echo "FEED_ALL_ATOM = 'feeds/all.atom.xml'";
|
||||||
echo "CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'" >> $STATIC_BLOG_FILE
|
echo "CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'";
|
||||||
echo '' >> $STATIC_BLOG_FILE
|
echo '';
|
||||||
echo 'DELETE_OUTPUT_DIRECTORY = True' >> $STATIC_BLOG_FILE
|
echo 'DELETE_OUTPUT_DIRECTORY = True'; } > "$STATIC_BLOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function pelican_themes {
|
function pelican_themes {
|
||||||
|
@ -747,10 +756,11 @@ function pelican_themes {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mesh_install_pelican {
|
function mesh_install_pelican {
|
||||||
if [[ $VARIANT != "meshclient" && $VARIANT != "meshusb" && $VARIANT != "usb" ]]; then
|
if [[ "$VARIANT" != "meshclient" && "$VARIANT" != "meshusb" && "$VARIANT" != "usb" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
chroot "$rootdir" apt-get -yq install python-pip
|
chroot "$rootdir" apt-get -yq install python-pip
|
||||||
chroot "$rootdir" pip install ipython
|
chroot "$rootdir" pip install ipython
|
||||||
chroot "$rootdir" pip install Markdown
|
chroot "$rootdir" pip install Markdown
|
||||||
|
@ -760,34 +770,34 @@ function mesh_install_pelican {
|
||||||
PELICAN_BLOG_INSTALL_DIR=/home/$MY_USERNAME/CreateBlog
|
PELICAN_BLOG_INSTALL_DIR=/home/$MY_USERNAME/CreateBlog
|
||||||
PELICAN_BLOG_PATH=/home/$MY_USERNAME/Public/Blog
|
PELICAN_BLOG_PATH=/home/$MY_USERNAME/Public/Blog
|
||||||
|
|
||||||
if [ ! -d $rootdir$PELICAN_BLOG_INSTALL_DIR ]; then
|
if [ ! -d "$rootdir$PELICAN_BLOG_INSTALL_DIR" ]; then
|
||||||
mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR
|
mkdir -p "$rootdir$PELICAN_BLOG_INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $rootdir$PELICAN_BLOG_PATH ]; then
|
if [ ! -d "$rootdir$PELICAN_BLOG_PATH" ]; then
|
||||||
mkdir -p $rootdir$PELICAN_BLOG_PATH
|
mkdir -p "$rootdir$PELICAN_BLOG_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $rootdir$PELICAN_BLOG_INSTALL_DIR/content/images ]; then
|
if [ ! -d "$rootdir$PELICAN_BLOG_INSTALL_DIR/content/images" ]; then
|
||||||
mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR/content/images
|
mkdir -p "$rootdir$PELICAN_BLOG_INSTALL_DIR/content/images"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create_pelican_conf $rootdir$PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
|
create_pelican_conf "$rootdir$PELICAN_BLOG_INSTALL_DIR/pelicanconf.py"
|
||||||
create_pelican_makefile $rootdir$PELICAN_BLOG_INSTALL_DIR/Makefile
|
create_pelican_makefile "$rootdir$PELICAN_BLOG_INSTALL_DIR/Makefile"
|
||||||
create_pelican_publish_conf $rootdir$PELICAN_BLOG_INSTALL_DIR/publishconf.py
|
create_pelican_publish_conf "$rootdir$PELICAN_BLOG_INSTALL_DIR/publishconf.py"
|
||||||
|
|
||||||
mkdir -p $rootdir$PELICAN_BLOG_INSTALL_DIR/themes
|
mkdir -p "$rootdir$PELICAN_BLOG_INSTALL_DIR/themes"
|
||||||
cd $rootdir$PELICAN_BLOG_INSTALL_DIR/themes
|
cd "$rootdir$PELICAN_BLOG_INSTALL_DIR/themes" || exit 74624524
|
||||||
pelican_themes
|
pelican_themes
|
||||||
|
|
||||||
#git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$PELICAN_BLOG_INSTALL_DIR/plugins
|
#git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$PELICAN_BLOG_INSTALL_DIR/plugins
|
||||||
|
|
||||||
chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME $PELICAN_BLOG_INSTALL_DIR
|
chroot "$rootdir" chown -R "$MY_USERNAME":"$MY_USERNAME" "$PELICAN_BLOG_INSTALL_DIR"
|
||||||
chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Public
|
chroot "$rootdir" chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/Public"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_pelican {
|
function install_pelican {
|
||||||
if [ $INSTALLING_MESH ]; then
|
if [ "$INSTALLING_MESH" ]; then
|
||||||
mesh_install_pelican
|
mesh_install_pelican
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -800,29 +810,29 @@ function install_pelican {
|
||||||
|
|
||||||
PELICAN_BLOG_PATH=/var/www/$PELICAN_DOMAIN_NAME/htdocs
|
PELICAN_BLOG_PATH=/var/www/$PELICAN_DOMAIN_NAME/htdocs
|
||||||
|
|
||||||
if [ ! -d $PELICAN_BLOG_INSTALL_DIR ]; then
|
if [ ! -d "$PELICAN_BLOG_INSTALL_DIR" ]; then
|
||||||
mkdir -p $PELICAN_BLOG_INSTALL_DIR
|
mkdir -p "$PELICAN_BLOG_INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $PELICAN_BLOG_PATH ]; then
|
if [ ! -d $PELICAN_BLOG_PATH ]; then
|
||||||
mkdir -p $PELICAN_BLOG_PATH
|
mkdir -p $PELICAN_BLOG_PATH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $PELICAN_BLOG_INSTALL_DIR/content ]; then
|
if [ ! -d "$PELICAN_BLOG_INSTALL_DIR/content" ]; then
|
||||||
mkdir -p $PELICAN_BLOG_INSTALL_DIR/content
|
mkdir -p "$PELICAN_BLOG_INSTALL_DIR/content"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create_pelican_conf $PELICAN_BLOG_INSTALL_DIR/pelicanconf.py
|
create_pelican_conf "$PELICAN_BLOG_INSTALL_DIR/pelicanconf.py"
|
||||||
create_pelican_makefile $PELICAN_BLOG_INSTALL_DIR/Makefile
|
create_pelican_makefile "$PELICAN_BLOG_INSTALL_DIR/Makefile"
|
||||||
create_pelican_publish_conf $PELICAN_BLOG_INSTALL_DIR/publishconf.py
|
create_pelican_publish_conf "$PELICAN_BLOG_INSTALL_DIR/publishconf.py"
|
||||||
|
|
||||||
mkdir -p $PELICAN_THEMES_REPO $PELICAN_BLOG_INSTALL_DIR/themes
|
mkdir -p "$PELICAN_THEMES_REPO" "$PELICAN_BLOG_INSTALL_DIR/themes"
|
||||||
cd $PELICAN_THEMES_REPO $PELICAN_BLOG_INSTALL_DIR/themes
|
cd "$PELICAN_BLOG_INSTALL_DIR/themes" || exit 45357282883
|
||||||
pelican_themes
|
pelican_themes
|
||||||
|
|
||||||
#git clone --recursive $PELICAN_PLUGINS_REPO $PELICAN_BLOG_INSTALL_DIR/plugins
|
#git clone --recursive $PELICAN_PLUGINS_REPO $PELICAN_BLOG_INSTALL_DIR/plugins
|
||||||
|
|
||||||
chown -R $MY_USERNAME:$MY_USERNAME $PELICAN_BLOG_INSTALL_DIR
|
chown -R "$MY_USERNAME":"$MY_USERNAME" "$PELICAN_BLOG_INSTALL_DIR"
|
||||||
chown -R www-data:www-data $PELICAN_BLOG_PATH
|
chown -R www-data:www-data $PELICAN_BLOG_PATH
|
||||||
|
|
||||||
pelican_editor_config
|
pelican_editor_config
|
||||||
|
@ -834,7 +844,7 @@ function install_pelican {
|
||||||
install_pelican_website_onion
|
install_pelican_website_onion
|
||||||
|
|
||||||
pelican_regenerate_blog
|
pelican_regenerate_blog
|
||||||
if [ ! -d $PELICAN_BLOG_INSTALL_DIR/output ]; then
|
if [ ! -d "$PELICAN_BLOG_INSTALL_DIR/output" ]; then
|
||||||
echo $'Failed to generate pelican blog'
|
echo $'Failed to generate pelican blog'
|
||||||
exit 521892
|
exit 521892
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -66,17 +66,17 @@ function pihole_copy_files {
|
||||||
if [ ! -d /etc/.pihole ]; then
|
if [ ! -d /etc/.pihole ]; then
|
||||||
mkdir /etc/.pihole
|
mkdir /etc/.pihole
|
||||||
fi
|
fi
|
||||||
cp $INSTALL_DIR/pihole/adlists.default /etc/.pihole/adlists.default
|
cp "$INSTALL_DIR/pihole/adlists.default" /etc/.pihole/adlists.default
|
||||||
cp $INSTALL_DIR/pihole/adlists.default $piholeDir/adlists.default
|
cp "$INSTALL_DIR/pihole/adlists.default" $piholeDir/adlists.default
|
||||||
if [ ! -f $PIHOLE_CUSTOM_ADLIST ]; then
|
if [ ! -f $PIHOLE_CUSTOM_ADLIST ]; then
|
||||||
cp $INSTALL_DIR/pihole/adlists.default $PIHOLE_CUSTOM_ADLIST
|
cp "$INSTALL_DIR/pihole/adlists.default" $PIHOLE_CUSTOM_ADLIST
|
||||||
fi
|
fi
|
||||||
cp $INSTALL_DIR/pihole/advanced/Scripts/* /opt/$piholeBasename
|
cp "$INSTALL_DIR/pihole/advanced/Scripts/*" /opt/$piholeBasename
|
||||||
if [ -f /etc/dnsmasq.d/01-pihole.conf ]; then
|
if [ -f /etc/dnsmasq.d/01-pihole.conf ]; then
|
||||||
rm /etc/dnsmasq.d/01-pihole.conf
|
rm /etc/dnsmasq.d/01-pihole.conf
|
||||||
fi
|
fi
|
||||||
cp $INSTALL_DIR/pihole/advanced/pihole.cron /etc/cron.d/pihole
|
cp "$INSTALL_DIR/pihole/advanced/pihole.cron" /etc/cron.d/pihole
|
||||||
cp $INSTALL_DIR/pihole/gravity.sh /opt/$piholeBasename
|
cp "$INSTALL_DIR/pihole/gravity.sh" /opt/$piholeBasename
|
||||||
chmod +x /opt/pihole/*.sh
|
chmod +x /opt/pihole/*.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ function pihole_update {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f $HOME/${PROJECT_NAME}-wifi.cfg ]; then
|
if [ ! -f "$HOME/${PROJECT_NAME}-wifi.cfg" ]; then
|
||||||
PIHOLE_IFACE=eth0
|
PIHOLE_IFACE=eth0
|
||||||
else
|
else
|
||||||
read_config_param WIFI_INTERFACE
|
read_config_param WIFI_INTERFACE
|
||||||
|
@ -114,13 +114,13 @@ function pihole_update {
|
||||||
echo "piholeDNS1=${PIHOLE_DNS1}" >> ${setupVars}
|
echo "piholeDNS1=${PIHOLE_DNS1}" >> ${setupVars}
|
||||||
echo "piholeDNS2=${PIHOLE_DNS1}" >> ${setupVars}
|
echo "piholeDNS2=${PIHOLE_DNS1}" >> ${setupVars}
|
||||||
|
|
||||||
echo 'domain-needed' > /etc/dnsmasq.conf
|
{ echo 'domain-needed';
|
||||||
echo 'bogus-priv' >> /etc/dnsmasq.conf
|
echo 'bogus-priv';
|
||||||
echo 'no-resolv' >> /etc/dnsmasq.conf
|
echo 'no-resolv';
|
||||||
echo "server=${PIHOLE_DNS1}" >> /etc/dnsmasq.conf
|
echo "server=${PIHOLE_DNS1}";
|
||||||
echo "server=${PIHOLE_DNS2}" >> /etc/dnsmasq.conf
|
echo "server=${PIHOLE_DNS2}";
|
||||||
echo "interface=${PIHOLE_IFACE}" >> /etc/dnsmasq.conf
|
echo "interface=${PIHOLE_IFACE}";
|
||||||
echo 'listen-address=127.0.0.1' >> /etc/dnsmasq.conf
|
echo 'listen-address=127.0.0.1'; } > /etc/dnsmasq.conf
|
||||||
|
|
||||||
pihole -g
|
pihole -g
|
||||||
systemctl restart dnsmasq
|
systemctl restart dnsmasq
|
||||||
|
@ -132,8 +132,7 @@ function pihole_update {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pihole_change_upstream_dns {
|
function pihole_change_upstream_dns {
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Ad Blocker Upstream DNS" \
|
dialog --backtitle $"Ad Blocker Upstream DNS" \
|
||||||
--radiolist $"Pick a domain name service (DNS):" 28 50 19 \
|
--radiolist $"Pick a domain name service (DNS):" 28 50 19 \
|
||||||
1 $"Digital Courage" on \
|
1 $"Digital Courage" on \
|
||||||
|
@ -154,13 +153,15 @@ function pihole_change_upstream_dns {
|
||||||
16 $"DNS.Watch" off \
|
16 $"DNS.Watch" off \
|
||||||
17 $"uncensoreddns.org" off \
|
17 $"uncensoreddns.org" off \
|
||||||
18 $"Lorraine Data Network" off \
|
18 $"Lorraine Data Network" off \
|
||||||
19 $"Google" off 2> $data
|
19 $"Google" off 2> "$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) rm -f "$data"
|
||||||
255) exit 1;;
|
exit 1;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
case $(cat $data) in
|
case $(cat "$data") in
|
||||||
1) PIHOLE_DNS1='85.214.73.63'
|
1) PIHOLE_DNS1='85.214.73.63'
|
||||||
PIHOLE_DNS2='213.73.91.35'
|
PIHOLE_DNS2='213.73.91.35'
|
||||||
;;
|
;;
|
||||||
|
@ -218,10 +219,12 @@ function pihole_change_upstream_dns {
|
||||||
19) PIHOLE_DNS1='8.8.8.8'
|
19) PIHOLE_DNS1='8.8.8.8'
|
||||||
PIHOLE_DNS2='4.4.4.4'
|
PIHOLE_DNS2='4.4.4.4'
|
||||||
dialog --title $"WARNING" \
|
dialog --title $"WARNING" \
|
||||||
--msgbox $"\nGoogle's main purpose for providing DNS resolvers is to spy upon people and know which sites they are visiting.\n\nThis is something to consider, and you should only really be using Google DNS as a last resort if other resolvers are unavailable." 12 60
|
--msgbox $"\\nGoogle's main purpose for providing DNS resolvers is to spy upon people and know which sites they are visiting.\\n\\nThis is something to consider, and you should only really be using Google DNS as a last resort if other resolvers are unavailable." 12 60
|
||||||
;;
|
;;
|
||||||
255) exit 1;;
|
255) rm -f "$data"
|
||||||
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
write_config_param "PIHOLE_DNS1" "$PIHOLE_DNS1"
|
write_config_param "PIHOLE_DNS1" "$PIHOLE_DNS1"
|
||||||
write_config_param "PIHOLE_DNS2" "$PIHOLE_DNS2"
|
write_config_param "PIHOLE_DNS2" "$PIHOLE_DNS2"
|
||||||
}
|
}
|
||||||
|
@ -252,8 +255,7 @@ function pihole_resume {
|
||||||
function configure_interactive_pihole {
|
function configure_interactive_pihole {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
dialog --backtitle $"Freedombone Control Panel" \
|
||||||
--title $"Ad Blocker" \
|
--title $"Ad Blocker" \
|
||||||
--radiolist $"Choose an operation:" 16 70 7 \
|
--radiolist $"Choose an operation:" 16 70 7 \
|
||||||
|
@ -263,13 +265,15 @@ function configure_interactive_pihole {
|
||||||
4 $"Change upstream DNS servers" off \
|
4 $"Change upstream DNS servers" off \
|
||||||
5 $"Pause blocker" off \
|
5 $"Pause blocker" off \
|
||||||
6 $"Resume blocker" off \
|
6 $"Resume blocker" off \
|
||||||
7 $"Exit" on 2> $data
|
7 $"Exit" on 2> "$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) rm -f "$data"
|
||||||
255) exit 1;;
|
exit 1;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
case $(cat $data) in
|
case $(cat "$data") in
|
||||||
1) editor $PIHOLE_CUSTOM_ADLIST
|
1) editor $PIHOLE_CUSTOM_ADLIST
|
||||||
update_pihole_interactive
|
update_pihole_interactive
|
||||||
;;
|
;;
|
||||||
|
@ -286,8 +290,10 @@ function configure_interactive_pihole {
|
||||||
;;
|
;;
|
||||||
6) pihole_resume
|
6) pihole_resume
|
||||||
;;
|
;;
|
||||||
7) break;;
|
7) rm -f "$data"
|
||||||
|
break;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +312,7 @@ function upgrade_pihole {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit $INSTALL_DIR/pihole "pihole commit" "$PIHOLE_COMMIT" $PIHOLE_REPO
|
set_repo_commit "$INSTALL_DIR/pihole" "pihole commit" "$PIHOLE_COMMIT" $PIHOLE_REPO
|
||||||
|
|
||||||
pihole_copy_files
|
pihole_copy_files
|
||||||
pihole_update
|
pihole_update
|
||||||
|
@ -367,8 +373,8 @@ function remove_pihole {
|
||||||
rm /etc/cron.d/pihole
|
rm /etc/cron.d/pihole
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $INSTALL_DIR/pihole ]; then
|
if [ -d "$INSTALL_DIR/pihole" ]; then
|
||||||
rm -rf $INSTALL_DIR/pihole
|
rm -rf "$INSTALL_DIR/pihole"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
firewall_remove 53
|
firewall_remove 53
|
||||||
|
@ -391,27 +397,27 @@ function install_pihole {
|
||||||
|
|
||||||
systemctl enable dnsmasq
|
systemctl enable dnsmasq
|
||||||
|
|
||||||
if [ ! -d $INSTALL_DIR ]; then
|
if [ ! -d "$INSTALL_DIR" ]; then
|
||||||
mkdir -p $INSTALL_DIR
|
mkdir -p "$INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $INSTALL_DIR/pihole ]; then
|
if [ ! -d "$INSTALL_DIR/pihole" ]; then
|
||||||
cd $INSTALL_DIR
|
cd "$INSTALL_DIR" || exit 78245624527
|
||||||
|
|
||||||
if [ -d /repos/pihole ]; then
|
if [ -d /repos/pihole ]; then
|
||||||
mkdir pihole
|
mkdir pihole
|
||||||
cp -r -p /repos/pihole/. pihole
|
cp -r -p /repos/pihole/. pihole
|
||||||
cd pihole
|
cd pihole || exit 24572424684
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
git_clone $PIHOLE_REPO pihole
|
git_clone $PIHOLE_REPO pihole
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $INSTALL_DIR/pihole ]; then
|
if [ ! -d "$INSTALL_DIR/pihole" ]; then
|
||||||
exit 523925
|
exit 523925
|
||||||
fi
|
fi
|
||||||
cd $INSTALL_DIR/pihole
|
cd "$INSTALL_DIR/pihole" || exit 2682468242
|
||||||
git checkout $PIHOLE_COMMIT -b $PIHOLE_COMMIT
|
git checkout "$PIHOLE_COMMIT" -b "$PIHOLE_COMMIT"
|
||||||
set_completion_param "pihole commit" "$PIHOLE_COMMIT"
|
set_completion_param "pihole commit" "$PIHOLE_COMMIT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -420,21 +426,21 @@ function install_pihole {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# blank file which takes the place of ads
|
# blank file which takes the place of ads
|
||||||
echo '<html>' > /var/www/pihole/htdocs/index.html
|
{ echo '<html>';
|
||||||
echo '<body>' >> /var/www/pihole/htdocs/index.html
|
echo '<body>';
|
||||||
echo '</body>' >> /var/www/pihole/htdocs/index.html
|
echo '</body>';
|
||||||
echo '</html>' >> /var/www/pihole/htdocs/index.html
|
echo '</html>'; } > /var/www/pihole/htdocs/index.html
|
||||||
|
|
||||||
if [ ! -f $INSTALL_DIR/pihole/gravity.sh ]; then
|
if [ ! -f "$INSTALL_DIR/pihole/gravity.sh" ]; then
|
||||||
exit 26738
|
exit 26738
|
||||||
fi
|
fi
|
||||||
cp $INSTALL_DIR/pihole/gravity.sh /usr/local/bin/gravity.sh
|
cp "$INSTALL_DIR/pihole/gravity.sh" /usr/local/bin/gravity.sh
|
||||||
chmod 755 /usr/local/bin/gravity.sh
|
chmod 755 /usr/local/bin/gravity.sh
|
||||||
|
|
||||||
if [ ! -f $INSTALL_DIR/pihole/pihole ]; then
|
if [ ! -f "$INSTALL_DIR/pihole/pihole" ]; then
|
||||||
exit 52935
|
exit 52935
|
||||||
fi
|
fi
|
||||||
cp $INSTALL_DIR/pihole/pihole /usr/local/bin/pihole
|
cp "$INSTALL_DIR/pihole/pihole" /usr/local/bin/pihole
|
||||||
chmod 755 /usr/local/bin/pihole
|
chmod 755 /usr/local/bin/pihole
|
||||||
|
|
||||||
if [ ! -d $piholeDir ]; then
|
if [ ! -d $piholeDir ]; then
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -66,12 +66,12 @@ function logging_off_postactiv {
|
||||||
function postactiv_customise_logo {
|
function postactiv_customise_logo {
|
||||||
domain_name=$1
|
domain_name=$1
|
||||||
|
|
||||||
if [ -f /var/www/${domain_name}/htdocs/static/logo.png ]; then
|
if [ -f "/var/www/${domain_name}/htdocs/static/logo.png" ]; then
|
||||||
if [ -f ~/freedombone/img/postactiv.png ]; then
|
if [ -f ~/freedombone/img/postactiv.png ]; then
|
||||||
cp ~/freedombone/img/postactiv.png /var/www/${domain_name}/htdocs/static/logo.png
|
cp ~/freedombone/img/postactiv.png "/var/www/${domain_name}/htdocs/static/logo.png"
|
||||||
else
|
else
|
||||||
if [ -f /home/$MY_USERNAME/freedombone/img/postactiv.png ]; then
|
if [ -f "/home/$MY_USERNAME/freedombone/img/postactiv.png" ]; then
|
||||||
cp /home/$MY_USERNAME/freedombone/img/postactiv.png /var/www/${domain_name}/htdocs/static/logo.png
|
cp "/home/$MY_USERNAME/freedombone/img/postactiv.png" "/var/www/${domain_name}/htdocs/static/logo.png"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -80,13 +80,13 @@ function postactiv_customise_logo {
|
||||||
function remove_user_postactiv {
|
function remove_user_postactiv {
|
||||||
remove_username="$1"
|
remove_username="$1"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $remove_username --rmapp postactiv
|
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp postactiv
|
||||||
|
|
||||||
function_check get_completion_param
|
function_check get_completion_param
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
if [ -d /var/www/$POSTACTIV_DOMAIN_NAME ]; then
|
if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
cd /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 3658254254
|
||||||
php scripts/deleteprofile.php -n $remove_username -y
|
php scripts/deleteprofile.php -n "$remove_username" -y
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,13 +94,13 @@ function add_user_postactiv {
|
||||||
new_username="$1"
|
new_username="$1"
|
||||||
new_user_password="$2"
|
new_user_password="$2"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $new_username -a postactiv -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$new_username" -a postactiv -p "$new_user_password"
|
||||||
|
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
if [ -d /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs ]; then
|
if [ -d "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs" ]; then
|
||||||
cd /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 346846834
|
||||||
php scripts/registeruser.php -n $new_username -w "$new_user_password" -e "$new_username@$HOSTNAME"
|
php scripts/registeruser.php -n "$new_username" -w "$new_user_password" -e "$new_username@$HOSTNAME"
|
||||||
${PROJECT_NAME}-addemail -u $new_username -e "noreply@$POSTACTIV_DOMAIN_NAME" -g postactiv --public no
|
"${PROJECT_NAME}-addemail" -u "$new_username" -e "noreply@$POSTACTIV_DOMAIN_NAME" -g postactiv --public no
|
||||||
echo '0'
|
echo '0'
|
||||||
else
|
else
|
||||||
echo '1'
|
echo '1'
|
||||||
|
@ -108,7 +108,7 @@ function add_user_postactiv {
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_interactive_postactiv {
|
function install_interactive_postactiv {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -118,54 +118,54 @@ function install_interactive_postactiv {
|
||||||
POSTACTIV_DETAILS_COMPLETE=
|
POSTACTIV_DETAILS_COMPLETE=
|
||||||
while [ ! $POSTACTIV_DETAILS_COMPLETE ]
|
while [ ! $POSTACTIV_DETAILS_COMPLETE ]
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
trap "rm -f $data" 0 1 2 5 15
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"PostActiv Configuration" \
|
--title $"PostActiv Configuration" \
|
||||||
--form $"\nPlease enter your PostActiv details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
--form $"\\nPlease enter your PostActiv details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
||||||
$"Domain:" 1 1 "$(grep 'POSTACTIV_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
$"Domain:" 1 1 "$(grep 'POSTACTIV_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||||
$"Title:" 2 1 "$(grep '$POSTACTIV_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
|
$"Title:" 2 1 "$(grep "$POSTACTIV_TITLE" temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
|
||||||
$"Background image URL:" 3 1 "$(grep '$POSTACTIV_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
|
$"Background image URL:" 3 1 "$(grep "$POSTACTIV_BACKGROUND_IMAGE_URL" temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
|
||||||
$"Code:" 4 1 "$(grep 'POSTACTIV_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 25 33 255 \
|
$"Code:" 4 1 "$(grep 'POSTACTIV_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 25 33 255 \
|
||||||
2> $data
|
2> "$data"
|
||||||
else
|
else
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"PostActiv Configuration" \
|
--title $"PostActiv Configuration" \
|
||||||
--form $"\nPlease enter your PostActiv details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
--form $"\\nPlease enter your PostActiv details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
||||||
$"Domain:" 1 1 "$(grep 'POSTACTIV_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
$"Domain:" 1 1 "$(grep 'POSTACTIV_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||||
$"Title:" 2 1 "$(grep '$POSTACTIV_TITLE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
|
$"Title:" 2 1 "$(grep "$POSTACTIV_TITLE" temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
|
||||||
$"Background image URL:" 3 1 "$(grep '$POSTACTIV_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
|
$"Background image URL:" 3 1 "$(grep "$POSTACTIV_BACKGROUND_IMAGE_URL" temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
|
||||||
2> $data
|
2> "$data"
|
||||||
fi
|
fi
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) exit 1;;
|
||||||
255) exit 1;;
|
255) exit 1;;
|
||||||
esac
|
esac
|
||||||
POSTACTIV_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
POSTACTIV_DOMAIN_NAME=$(sed -n 1p < "$data")
|
||||||
title=$(cat $data | sed -n 2p)
|
title=$(sed -n 2p < "$data")
|
||||||
if [ ${#title} -gt 1 ]; then
|
if [ ${#title} -gt 1 ]; then
|
||||||
POSTACTIV_TITLE=$welcome_msg
|
POSTACTIV_TITLE=$title
|
||||||
fi
|
fi
|
||||||
img_url=$(cat $data | sed -n 3p)
|
img_url=$(sed -n 3p < "$data")
|
||||||
if [ ${#img_url} -gt 1 ]; then
|
if [ ${#img_url} -gt 1 ]; then
|
||||||
POSTACTIV_BACKGROUND_IMAGE_URL=$img_url
|
POSTACTIV_BACKGROUND_IMAGE_URL=$img_url
|
||||||
fi
|
fi
|
||||||
if [ $POSTACTIV_DOMAIN_NAME ]; then
|
if [ "$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
if [[ $POSTACTIV_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
if [[ "$POSTACTIV_DOMAIN_NAME" == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
||||||
POSTACTIV_DOMAIN_NAME=""
|
POSTACTIV_DOMAIN_NAME=""
|
||||||
fi
|
fi
|
||||||
TEST_DOMAIN_NAME=$POSTACTIV_DOMAIN_NAME
|
TEST_DOMAIN_NAME=$POSTACTIV_DOMAIN_NAME
|
||||||
validate_domain_name
|
validate_domain_name
|
||||||
if [[ $TEST_DOMAIN_NAME != $POSTACTIV_DOMAIN_NAME ]]; then
|
if [[ "$TEST_DOMAIN_NAME" != "$POSTACTIV_DOMAIN_NAME" ]]; then
|
||||||
POSTACTIV_DOMAIN_NAME=
|
POSTACTIV_DOMAIN_NAME=
|
||||||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||||||
else
|
else
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
POSTACTIV_CODE=$(cat $data | sed -n 4p)
|
POSTACTIV_CODE=$(sed -n 4p < "$data")
|
||||||
validate_freedns_code "$POSTACTIV_CODE"
|
validate_freedns_code "$POSTACTIV_CODE"
|
||||||
if [ ! $VALID_CODE ]; then
|
if [ ! "$VALID_CODE" ]; then
|
||||||
POSTACTIV_DOMAIN_NAME=
|
POSTACTIV_DOMAIN_NAME=
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -178,7 +178,7 @@ function install_interactive_postactiv {
|
||||||
|
|
||||||
# remove any invalid characters
|
# remove any invalid characters
|
||||||
if [ ${#POSTACTIV_TITLE} -gt 0 ]; then
|
if [ ${#POSTACTIV_TITLE} -gt 0 ]; then
|
||||||
new_title=$(echo "$POSTACTIV_TITLE" | sed "s|'||g")
|
new_title=${"$POSTACTIV_TITLE"//\'//}
|
||||||
POSTACTIV_TITLE="$new_title"
|
POSTACTIV_TITLE="$new_title"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -197,26 +197,26 @@ function change_password_postactiv {
|
||||||
|
|
||||||
read_config_param 'POSTACTIV_DOMAIN_NAME'
|
read_config_param 'POSTACTIV_DOMAIN_NAME'
|
||||||
|
|
||||||
cd /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/scripts
|
cd "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/scripts" || exit 246824682
|
||||||
php setpassword.php "$curr_username" "$new_user_password"
|
php setpassword.php "$curr_username" "$new_user_password"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u "$curr_username" -a postactiv -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a postactiv -p "$new_user_password"
|
||||||
}
|
}
|
||||||
|
|
||||||
function postactiv_create_database {
|
function postactiv_create_database {
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
POSTACTIV_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
POSTACTIV_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
if [ ! $POSTACTIV_ADMIN_PASSWORD ]; then
|
if [ ! "$POSTACTIV_ADMIN_PASSWORD" ]; then
|
||||||
POSTACTIV_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
POSTACTIV_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! $POSTACTIV_ADMIN_PASSWORD ]; then
|
if [ ! "$POSTACTIV_ADMIN_PASSWORD" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check create_database
|
function_check create_database
|
||||||
create_database postactiv "$POSTACTIV_ADMIN_PASSWORD" $MY_USERNAME
|
create_database postactiv "$POSTACTIV_ADMIN_PASSWORD" "$MY_USERNAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function postactiv_running_script {
|
function postactiv_running_script {
|
||||||
|
@ -235,64 +235,63 @@ function reconfigure_postactiv {
|
||||||
function postactiv_set_background_image {
|
function postactiv_set_background_image {
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
|
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --title $"PostActiv" \
|
dialog --title $"PostActiv" \
|
||||||
--backtitle $"Freedombone Control Panel" \
|
--backtitle $"Freedombone Control Panel" \
|
||||||
--inputbox $'Set a background image URL' 10 60 2>$data
|
--inputbox $'Set a background image URL' 10 60 2>"$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
0)
|
0)
|
||||||
temp_background=$(<$data)
|
temp_background=$(<"$data")
|
||||||
if [ ${#temp_background} -gt 0 ]; then
|
if [ ${#temp_background} -gt 0 ]; then
|
||||||
POSTACTIV_BACKGROUND_IMAGE_URL="$temp_background"
|
POSTACTIV_BACKGROUND_IMAGE_URL="$temp_background"
|
||||||
write_config_param "POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_BACKGROUND_IMAGE_URL"
|
write_config_param "POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_BACKGROUND_IMAGE_URL"
|
||||||
|
|
||||||
if [[ $(pleroma_set_background_image_from_url /var/www/$POSTACTIV_DOMAIN_NAME/htdocs "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE" | tail -n 1) == "0" ]]; then
|
if [[ $(pleroma_set_background_image_from_url "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE" | tail -n 1) == "0" ]]; then
|
||||||
dialog --title $"Set PostActiv background" \
|
dialog --title $"Set PostActiv background" \
|
||||||
--msgbox $"The background image has been set" 6 60
|
--msgbox $"The background image has been set" 6 60
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
}
|
}
|
||||||
|
|
||||||
function postactiv_set_title {
|
function postactiv_set_title {
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --title $"PostActiv" \
|
dialog --title $"PostActiv" \
|
||||||
--backtitle $"Freedombone Control Panel" \
|
--backtitle $"Freedombone Control Panel" \
|
||||||
--inputbox $'Set a title' 10 60 2>$data
|
--inputbox $'Set a title' 10 60 2>"$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
0)
|
0)
|
||||||
new_title=$(<$data)
|
new_title=$(<"$data")
|
||||||
if [ ${#new_title} -gt 0 ]; then
|
if [ ${#new_title} -gt 0 ]; then
|
||||||
POSTACTIV_TITLE="$new_title"
|
POSTACTIV_TITLE="$new_title"
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
write_config_param "POSTACTIV_TITLE" "$POSTACTIV_TITLE"
|
write_config_param "POSTACTIV_TITLE" "$POSTACTIV_TITLE"
|
||||||
cd /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/static
|
cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/static" || exit 782452452
|
||||||
sed -i "s|\"name\":.*|\"name\": \"${POSTACTIV_TITLE}\",|g" config.json
|
sed -i "s|\"name\":.*|\"name\": \"${POSTACTIV_TITLE}\",|g" config.json
|
||||||
dialog --title $"Set PostActiv title" \
|
dialog --title $"Set PostActiv title" \
|
||||||
--msgbox $"The title has been set" 6 60
|
--msgbox $"The title has been set" 6 60
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
}
|
}
|
||||||
|
|
||||||
function postactiv_set_expire_months {
|
function postactiv_set_expire_months {
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
read_config_param "POSTACTIV_EXPIRE_MONTHS"
|
read_config_param "POSTACTIV_EXPIRE_MONTHS"
|
||||||
|
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --title $"PostActiv" \
|
dialog --title $"PostActiv" \
|
||||||
--backtitle $"Freedombone Control Panel" \
|
--backtitle $"Freedombone Control Panel" \
|
||||||
--inputbox $'Set an expiry period for posts in months. Anything older will be deleted. Lower values help to keep the database size small and as fast as possible.' 12 60 "$POSTACTIV_EXPIRE_MONTHS" 2>$data
|
--inputbox $'Set an expiry period for posts in months. Anything older will be deleted. Lower values help to keep the database size small and as fast as possible.' 12 60 "$POSTACTIV_EXPIRE_MONTHS" 2>"$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
0)
|
0)
|
||||||
new_expiry_months=$(<$data)
|
new_expiry_months=$(<"$data")
|
||||||
if [ ${#new_expiry_months} -gt 0 ]; then
|
if [ ${#new_expiry_months} -gt 0 ]; then
|
||||||
# should contain no spaces
|
# should contain no spaces
|
||||||
if [[ "$new_expiry_months" == *" "* ]]; then
|
if [[ "$new_expiry_months" == *" "* ]]; then
|
||||||
|
@ -312,14 +311,14 @@ function postactiv_set_expire_months {
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_interactive_postactiv {
|
function configure_interactive_postactiv {
|
||||||
read_config_param "POSTACTIV_EXPIRE_MONTHS"
|
read_config_param "POSTACTIV_EXPIRE_MONTHS"
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
dialog --backtitle $"Freedombone Control Panel" \
|
||||||
--title $"PostActiv" \
|
--title $"PostActiv" \
|
||||||
--radiolist $"Choose an operation:" 16 70 7 \
|
--radiolist $"Choose an operation:" 16 70 7 \
|
||||||
|
@ -329,21 +328,25 @@ function configure_interactive_postactiv {
|
||||||
4 $"Select Qvitter user interface" off \
|
4 $"Select Qvitter user interface" off \
|
||||||
5 $"Select Pleroma user interface" off \
|
5 $"Select Pleroma user interface" off \
|
||||||
6 $"Select Classic user interface" off \
|
6 $"Select Classic user interface" off \
|
||||||
7 $"Exit" on 2> $data
|
7 $"Exit" on 2> "$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) return;;
|
1) rm -f "$data"
|
||||||
255) return;;
|
return;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
return;;
|
||||||
esac
|
esac
|
||||||
case $(cat $data) in
|
case $(cat "$data") in
|
||||||
1) postactiv_set_background_image;;
|
1) postactiv_set_background_image;;
|
||||||
2) postactiv_set_title;;
|
2) postactiv_set_title;;
|
||||||
3) postactiv_set_expire_months;;
|
3) postactiv_set_expire_months;;
|
||||||
4) gnusocial_use_qvitter postactiv;;
|
4) gnusocial_use_qvitter postactiv;;
|
||||||
5) gnusocial_use_pleroma postactiv;;
|
5) gnusocial_use_pleroma postactiv;;
|
||||||
6) gnusocial_use_classic postactiv;;
|
6) gnusocial_use_classic postactiv;;
|
||||||
7) break;;
|
7) rm -f "$data"
|
||||||
|
break;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,22 +356,22 @@ function upgrade_postactiv {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "postactiv domain" $COMPLETION_FILE; then
|
if grep -q "postactiv domain" "$COMPLETION_FILE"; then
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update to the next commit
|
# update to the next commit
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit /var/www/$POSTACTIV_DOMAIN_NAME/htdocs "postactiv commit" "$POSTACTIV_COMMIT" $POSTACTIV_REPO
|
set_repo_commit "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" "postactiv commit" "$POSTACTIV_COMMIT" $POSTACTIV_REPO
|
||||||
|
|
||||||
# Ensure that installation script is removed
|
# Ensure that installation script is removed
|
||||||
if [ -f /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php ]; then
|
if [ -f "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php" ]; then
|
||||||
rm /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php
|
rm "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index_qvitter.php ]; then
|
if [ -f "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index_qvitter.php" ]; then
|
||||||
if [ -f /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index.php ]; then
|
if [ -f "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index.php" ]; then
|
||||||
mv /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index.php /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index_qvitter.php
|
mv "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index.php" "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/index_qvitter.php"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -379,16 +382,16 @@ function upgrade_postactiv {
|
||||||
gnusocial_block_domain_script postactiv "$POSTACTIV_DOMAIN_NAME"
|
gnusocial_block_domain_script postactiv "$POSTACTIV_DOMAIN_NAME"
|
||||||
|
|
||||||
upgrade_pleroma_frontend "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
|
upgrade_pleroma_frontend "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
|
||||||
postactiv_customise_logo
|
postactiv_customise_logo "$POSTACTIV_DOMAIN_NAME"
|
||||||
install_gnusocial_default_background "postactiv" "$POSTACTIV_DOMAIN_NAME"
|
install_gnusocial_default_background "postactiv" "$POSTACTIV_DOMAIN_NAME"
|
||||||
chown -R www-data:www-data /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
|
chown -R www-data:www-data "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs"
|
||||||
systemctl restart mariadb
|
systemctl restart mariadb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function backup_local_postactiv {
|
function backup_local_postactiv {
|
||||||
POSTACTIV_DOMAIN_NAME='postactiv'
|
POSTACTIV_DOMAIN_NAME='postactiv'
|
||||||
if grep -q "postactiv domain" $COMPLETION_FILE; then
|
if grep -q "postactiv domain" "$COMPLETION_FILE"; then
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -396,24 +399,24 @@ function backup_local_postactiv {
|
||||||
/etc/cron.daily/postactiv-expire
|
/etc/cron.daily/postactiv-expire
|
||||||
|
|
||||||
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
|
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
|
||||||
if [ ! -d $source_directory ]; then
|
if [ ! -d "$source_directory" ]; then
|
||||||
mkdir $source_directory
|
mkdir "$source_directory"
|
||||||
fi
|
fi
|
||||||
cp -p /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php $source_directory
|
cp -p "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php" "$source_directory"
|
||||||
if [ -d /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static ]; then
|
if [ -d "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" ]; then
|
||||||
cp -rp /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static $source_directory
|
cp -rp "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" "$source_directory"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${POSTACTIV_DOMAIN_NAME}
|
suspend_site "${POSTACTIV_DOMAIN_NAME}"
|
||||||
|
|
||||||
function_check backup_directory_to_usb
|
function_check backup_directory_to_usb
|
||||||
dest_directory=postactivconfig
|
dest_directory=postactivconfig
|
||||||
backup_directory_to_usb $source_directory $dest_directory
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
|
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
|
||||||
dest_directory=postactivfile
|
dest_directory=postactivfile
|
||||||
backup_directory_to_usb $source_directory $dest_directory
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
function_check backup_database_to_usb
|
function_check backup_database_to_usb
|
||||||
backup_database_to_usb postactiv
|
backup_database_to_usb postactiv
|
||||||
|
@ -423,16 +426,16 @@ function backup_local_postactiv {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_local_postactiv {
|
function restore_local_postactiv {
|
||||||
if ! grep -q "postactiv domain" $COMPLETION_FILE; then
|
if ! grep -q "postactiv domain" "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
if [ $POSTACTIV_DOMAIN_NAME ]; then
|
if [ "$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
echo $"Restoring postactiv"
|
echo $"Restoring postactiv"
|
||||||
temp_restore_dir=/root/temppostactiv
|
temp_restore_dir=/root/temppostactiv
|
||||||
postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
|
postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
|
||||||
# stop the daemons
|
# stop the daemons
|
||||||
cd $postactiv_dir
|
cd "$postactiv_dir" || exit 468246242
|
||||||
scripts/stopdaemons.sh
|
scripts/stopdaemons.sh
|
||||||
|
|
||||||
function_check postactiv_create_database
|
function_check postactiv_create_database
|
||||||
|
@ -446,36 +449,36 @@ function restore_local_postactiv {
|
||||||
function_check restore_directory_from_usb
|
function_check restore_directory_from_usb
|
||||||
restore_directory_from_usb $temp_restore_dir postactivconfig
|
restore_directory_from_usb $temp_restore_dir postactivconfig
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
if [ -d $temp_restore_dir$postactiv_dir ]; then
|
if [ -d "$temp_restore_dir$postactiv_dir" ]; then
|
||||||
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
|
cp "$temp_restore_dir$postactiv_dir/backup/config.php" "$postactiv_dir/"
|
||||||
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
|
cp -rp "$temp_restore_dir$postactiv_dir/static" "$postactiv_dir/"
|
||||||
else
|
else
|
||||||
cp $temp_restore_dir/backup/config.php $postactiv_dir/
|
cp "$temp_restore_dir/backup/config.php" "$postactiv_dir/"
|
||||||
if [ ! -d $postactiv_dir/static ]; then
|
if [ ! -d "$postactiv_dir/static" ]; then
|
||||||
mkdir $postactiv_dir/static
|
mkdir "$postactiv_dir/static"
|
||||||
fi
|
fi
|
||||||
cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
|
cp -rp "$temp_restore_dir/static/*" "$postactiv_dir/static/"
|
||||||
fi
|
fi
|
||||||
chown www-data:www-data $postactiv_dir/config.php
|
chown www-data:www-data "$postactiv_dir/config.php"
|
||||||
chown -R www-data:www-data $postactiv_dir/static
|
chown -R www-data:www-data "$postactiv_dir/static"
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
restore_directory_from_usb $temp_restore_dir postactivfile
|
restore_directory_from_usb $temp_restore_dir postactivfile
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
if [ -d $temp_restore_dir$postactiv_dir/file ]; then
|
if [ -d "$temp_restore_dir$postactiv_dir/file" ]; then
|
||||||
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
|
cp -rp "$temp_restore_dir$postactiv_dir/file" "$postactiv_dir/"
|
||||||
else
|
else
|
||||||
if [ ! -d $postactiv_dir/file ]; then
|
if [ ! -d "$postactiv_dir/file" ]; then
|
||||||
mkdir $postactiv_dir/file
|
mkdir "$postactiv_dir/file"
|
||||||
fi
|
fi
|
||||||
cp -rp $temp_restore_dir/* $postactiv_dir/file/
|
cp -rp "$temp_restore_dir/*" "$postactiv_dir/file/"
|
||||||
fi
|
fi
|
||||||
chown -R www-data:www-data $postactiv_dir/file
|
chown -R www-data:www-data "$postactiv_dir/file"
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gnusocial_update_after_restore postactiv ${POSTACTIV_DOMAIN_NAME}
|
gnusocial_update_after_restore postactiv "${POSTACTIV_DOMAIN_NAME}"
|
||||||
|
|
||||||
echo $"Restore of postactiv complete"
|
echo $"Restore of postactiv complete"
|
||||||
fi
|
fi
|
||||||
|
@ -483,7 +486,7 @@ function restore_local_postactiv {
|
||||||
|
|
||||||
function backup_remote_postactiv {
|
function backup_remote_postactiv {
|
||||||
POSTACTIV_DOMAIN_NAME='postactiv'
|
POSTACTIV_DOMAIN_NAME='postactiv'
|
||||||
if grep -q "postactiv domain" $COMPLETION_FILE; then
|
if grep -q "postactiv domain" "$COMPLETION_FILE"; then
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -491,24 +494,24 @@ function backup_remote_postactiv {
|
||||||
/etc/cron.daily/postactiv-expire
|
/etc/cron.daily/postactiv-expire
|
||||||
|
|
||||||
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
|
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
|
||||||
if [ ! -d $source_directory ]; then
|
if [ ! -d "$source_directory" ]; then
|
||||||
mkdir $source_directory
|
mkdir "$source_directory"
|
||||||
fi
|
fi
|
||||||
cp -p /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php $source_directory
|
cp -p "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php" "$source_directory"
|
||||||
if [ -d /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static ]; then
|
if [ -d "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" ]; then
|
||||||
cp -rp /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static $source_directory
|
cp -rp "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static" "$source_directory"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${POSTACTIV_DOMAIN_NAME}
|
suspend_site "${POSTACTIV_DOMAIN_NAME}"
|
||||||
|
|
||||||
function_check backup_directory_to_friend
|
function_check backup_directory_to_friend
|
||||||
dest_directory=postactivconfig
|
dest_directory=postactivconfig
|
||||||
backup_directory_to_friend $source_directory $dest_directory
|
backup_directory_to_friend "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
|
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
|
||||||
dest_directory=postactivfile
|
dest_directory=postactivfile
|
||||||
backup_directory_to_friend $source_directory $dest_directory
|
backup_directory_to_friend "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
function_check backup_database_to_friend
|
function_check backup_database_to_friend
|
||||||
backup_database_to_friend postactiv
|
backup_database_to_friend postactiv
|
||||||
|
@ -518,16 +521,16 @@ function backup_remote_postactiv {
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_remote_postactiv {
|
function restore_remote_postactiv {
|
||||||
if ! grep -q "postactiv domain" $COMPLETION_FILE; then
|
if ! grep -q "postactiv domain" "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
|
||||||
if [ $POSTACTIV_DOMAIN_NAME ]; then
|
if [ "$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
echo $"Restoring postactiv"
|
echo $"Restoring postactiv"
|
||||||
temp_restore_dir=/root/temppostactiv
|
temp_restore_dir=/root/temppostactiv
|
||||||
postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
|
postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
|
||||||
# stop the daemons
|
# stop the daemons
|
||||||
cd $postactiv_dir
|
cd "$postactiv_dir" || exit 24682464
|
||||||
scripts/stopdaemons.sh
|
scripts/stopdaemons.sh
|
||||||
|
|
||||||
function_check postactiv_create_database
|
function_check postactiv_create_database
|
||||||
|
@ -542,36 +545,36 @@ function restore_remote_postactiv {
|
||||||
function_check restore_directory_from_friend
|
function_check restore_directory_from_friend
|
||||||
restore_directory_from_friend $temp_restore_dir postactivconfig
|
restore_directory_from_friend $temp_restore_dir postactivconfig
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
if [ -d $temp_restore_dir$postactiv_dir ]; then
|
if [ -d "$temp_restore_dir$postactiv_dir" ]; then
|
||||||
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
|
cp "$temp_restore_dir$postactiv_dir/backup/config.php" "$postactiv_dir/"
|
||||||
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
|
cp -rp "$temp_restore_dir$postactiv_dir/static" "$postactiv_dir/"
|
||||||
else
|
else
|
||||||
cp $temp_restore_dir/config.php $postactiv_dir/
|
cp "$temp_restore_dir/config.php" "$postactiv_dir/"
|
||||||
if [ ! -d $postactiv_dir/static ]; then
|
if [ ! -d "$postactiv_dir/static" ]; then
|
||||||
mkdir $postactiv_dir/static
|
mkdir "$postactiv_dir/static"
|
||||||
fi
|
fi
|
||||||
cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
|
cp -rp "$temp_restore_dir/static/*" "$postactiv_dir/static/"
|
||||||
fi
|
fi
|
||||||
chown www-data:www-data $postactiv_dir/config.php
|
chown www-data:www-data "$postactiv_dir/config.php"
|
||||||
chown -R www-data:www-data $postactiv_dir/static
|
chown -R www-data:www-data "$postactiv_dir/static"
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
restore_directory_from_friend $temp_restore_dir postactivfile
|
restore_directory_from_friend $temp_restore_dir postactivfile
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
if [ -d $temp_restore_dir$postactiv_dir/file ]; then
|
if [ -d "$temp_restore_dir$postactiv_dir/file" ]; then
|
||||||
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
|
cp -rp "$temp_restore_dir$postactiv_dir/file" "$postactiv_dir/"
|
||||||
else
|
else
|
||||||
if [ ! -d $postactiv_dir/file ]; then
|
if [ ! -d "$postactiv_dir/file" ]; then
|
||||||
mkdir $postactiv_dir/file
|
mkdir "$postactiv_dir/file"
|
||||||
fi
|
fi
|
||||||
cp -rp $temp_restore_dir/* $postactiv_dir/file/
|
cp -rp "$temp_restore_dir/*" "$postactiv_dir/file/"
|
||||||
fi
|
fi
|
||||||
chown -R www-data:www-data $postactiv_dir/file
|
chown -R www-data:www-data "$postactiv_dir/file"
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gnusocial_update_after_restore postactiv ${POSTACTIV_DOMAIN_NAME}
|
gnusocial_update_after_restore postactiv "${POSTACTIV_DOMAIN_NAME}"
|
||||||
|
|
||||||
echo $"Restore of postactiv complete"
|
echo $"Restore of postactiv complete"
|
||||||
fi
|
fi
|
||||||
|
@ -587,23 +590,23 @@ function remove_postactiv {
|
||||||
read_config_param "POSTACTIV_DOMAIN_NAME"
|
read_config_param "POSTACTIV_DOMAIN_NAME"
|
||||||
read_config_param "MY_USERNAME"
|
read_config_param "MY_USERNAME"
|
||||||
echo "Removing $POSTACTIV_DOMAIN_NAME"
|
echo "Removing $POSTACTIV_DOMAIN_NAME"
|
||||||
nginx_dissite $POSTACTIV_DOMAIN_NAME
|
nginx_dissite "$POSTACTIV_DOMAIN_NAME"
|
||||||
remove_certs $POSTACTIV_DOMAIN_NAME
|
remove_certs "$POSTACTIV_DOMAIN_NAME"
|
||||||
if [ -f /etc/cron.hourly/postactiv-daemons ]; then
|
if [ -f /etc/cron.hourly/postactiv-daemons ]; then
|
||||||
rm /etc/cron.hourly/postactiv-daemons
|
rm /etc/cron.hourly/postactiv-daemons
|
||||||
fi
|
fi
|
||||||
if [ -f /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/stopdaemons.sh ]; then
|
if [ -f "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/stopdaemons.sh" ]; then
|
||||||
cd /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 2467245248
|
||||||
scripts/stopdaemons.sh
|
scripts/stopdaemons.sh
|
||||||
fi
|
fi
|
||||||
kill_pid=$(ps aux | grep /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php | awk -F ' ' '{print $2}' | head -n 1)
|
kill_pid=$(pgrep "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1)
|
||||||
kill -9 $kill_pid
|
kill -9 "$kill_pid"
|
||||||
|
|
||||||
if [ -d /var/www/$POSTACTIV_DOMAIN_NAME ]; then
|
if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
rm -rf /var/www/$POSTACTIV_DOMAIN_NAME
|
rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ -f /etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME ]; then
|
if [ -f "/etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
rm /etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME
|
rm "/etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
function_check drop_database
|
function_check drop_database
|
||||||
drop_database postactiv
|
drop_database postactiv
|
||||||
|
@ -614,17 +617,17 @@ function remove_postactiv {
|
||||||
fi
|
fi
|
||||||
remove_app postactiv
|
remove_app postactiv
|
||||||
remove_completion_param install_postactiv
|
remove_completion_param install_postactiv
|
||||||
sed -i '/postactiv/d' $COMPLETION_FILE
|
sed -i '/postactiv/d' "$COMPLETION_FILE"
|
||||||
remove_backup_database_local postactiv
|
remove_backup_database_local postactiv
|
||||||
|
|
||||||
sed -i '/postactiv-firewall/d' /etc/crontab
|
sed -i '/postactiv-firewall/d' /etc/crontab
|
||||||
|
|
||||||
function_check remove_ddns_domain
|
function_check remove_ddns_domain
|
||||||
remove_ddns_domain $POSTACTIV_DOMAIN_NAME
|
remove_ddns_domain "$POSTACTIV_DOMAIN_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_postactiv_main {
|
function install_postactiv_main {
|
||||||
if [ ! $POSTACTIV_DOMAIN_NAME ]; then
|
if [ ! "$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
echo $'No domain name was given for postactiv'
|
echo $'No domain name was given for postactiv'
|
||||||
exit 7359
|
exit 7359
|
||||||
fi
|
fi
|
||||||
|
@ -648,38 +651,38 @@ function install_postactiv_main {
|
||||||
apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
|
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
|
apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
|
||||||
|
|
||||||
if [ ! -d /var/www/$POSTACTIV_DOMAIN_NAME ]; then
|
if [ ! -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
|
||||||
mkdir /var/www/$POSTACTIV_DOMAIN_NAME
|
mkdir "/var/www/$POSTACTIV_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ ! -d /var/www/$POSTACTIV_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" ]; then
|
||||||
|
|
||||||
if [ -d /repos/postactiv ]; then
|
if [ -d /repos/postactiv ]; then
|
||||||
mkdir /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
mkdir "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
|
||||||
cp -r -p /repos/postactiv/. /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
cp -r -p /repos/postactiv/. "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
|
||||||
cd /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 46824682682
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
git_clone $POSTACTIV_REPO /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
git_clone "$POSTACTIV_REPO" "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /var/www/$POSTACTIV_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" ]; then
|
||||||
echo $'Unable to clone postactiv repo'
|
echo $'Unable to clone postactiv repo'
|
||||||
exit 87525
|
exit 87525
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 46287462828
|
||||||
git checkout $POSTACTIV_COMMIT -b $POSTACTIV_COMMIT
|
git checkout $POSTACTIV_COMMIT -b $POSTACTIV_COMMIT
|
||||||
set_completion_param "postactiv commit" "$POSTACTIV_COMMIT"
|
set_completion_param "postactiv commit" "$POSTACTIV_COMMIT"
|
||||||
|
|
||||||
chmod g+w /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
chmod g+w "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
|
||||||
chmod a+w /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/avatar
|
chmod a+w "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/avatar"
|
||||||
chmod a+w /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/file
|
chmod a+w "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/file"
|
||||||
chown -R www-data:www-data /var/www/$POSTACTIV_DOMAIN_NAME/htdocs
|
chown -R www-data:www-data "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs"
|
||||||
chmod +x /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/maildaemon.php
|
chmod +x "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/maildaemon.php"
|
||||||
chmod 755 /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/extlib/HTMLPurifier/HTMLPurifier/DefinitionCache/Serializer.php
|
chmod 755 "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/extlib/HTMLPurifier/HTMLPurifier/DefinitionCache/Serializer.php"
|
||||||
chmod -x /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/extlib/HTMLPurifier/HTMLPurifier/DefinitionCache/Serializer.php
|
chmod -x "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/extlib/HTMLPurifier/HTMLPurifier/DefinitionCache/Serializer.php"
|
||||||
|
|
||||||
function_check postactiv_create_database
|
function_check postactiv_create_database
|
||||||
postactiv_create_database
|
postactiv_create_database
|
||||||
|
@ -695,118 +698,118 @@ function install_postactiv_main {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check add_ddns_domain
|
function_check add_ddns_domain
|
||||||
add_ddns_domain $POSTACTIV_DOMAIN_NAME
|
add_ddns_domain "$POSTACTIV_DOMAIN_NAME"
|
||||||
|
|
||||||
POSTACTIV_ONION_HOSTNAME=$(add_onion_service postactiv 80 ${POSTACTIV_ONION_PORT})
|
POSTACTIV_ONION_HOSTNAME=$(add_onion_service postactiv 80 ${POSTACTIV_ONION_PORT})
|
||||||
|
|
||||||
postactiv_nginx_site=/etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME
|
postactiv_nginx_site=/etc/nginx/sites-available/$POSTACTIV_DOMAIN_NAME
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $POSTACTIV_DOMAIN_NAME "index index.php"
|
nginx_http_redirect "$POSTACTIV_DOMAIN_NAME" "index index.php"
|
||||||
echo 'server {' >> $postactiv_nginx_site
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> $postactiv_nginx_site
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> $postactiv_nginx_site
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo " server_name $POSTACTIV_DOMAIN_NAME;" >> $postactiv_nginx_site
|
echo " server_name $POSTACTIV_DOMAIN_NAME;";
|
||||||
echo '' >> $postactiv_nginx_site
|
echo ''; } >> "$postactiv_nginx_site"
|
||||||
function_check nginx_compress
|
function_check nginx_compress
|
||||||
nginx_compress $POSTACTIV_DOMAIN_NAME
|
nginx_compress "$POSTACTIV_DOMAIN_NAME"
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '' >> "$postactiv_nginx_site"
|
||||||
echo ' # Security' >> $postactiv_nginx_site
|
echo ' # Security' >> "$postactiv_nginx_site"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $POSTACTIV_DOMAIN_NAME
|
nginx_ssl "$POSTACTIV_DOMAIN_NAME"
|
||||||
|
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $POSTACTIV_DOMAIN_NAME
|
nginx_disable_sniffing "$POSTACTIV_DOMAIN_NAME"
|
||||||
|
|
||||||
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $postactiv_nginx_site
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Logs' >> $postactiv_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $postactiv_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $postactiv_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $postactiv_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$POSTACTIV_DOMAIN_NAME/htdocs;" >> $postactiv_nginx_site
|
echo " root /var/www/$POSTACTIV_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Index' >> $postactiv_nginx_site
|
echo ' # Index';
|
||||||
echo ' index index.php;' >> $postactiv_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # PHP' >> $postactiv_nginx_site
|
echo ' # PHP';
|
||||||
echo ' location ~ \.php {' >> $postactiv_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $postactiv_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $postactiv_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $postactiv_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $postactiv_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $postactiv_nginx_site
|
echo ' location / {'; } >> "$postactiv_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $POSTACTIV_DOMAIN_NAME '15m'
|
nginx_limits "$POSTACTIV_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @postactiv;' >> $postactiv_nginx_site
|
{ echo " try_files \$uri \$uri/ @postactiv;";
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Fancy URLs' >> $postactiv_nginx_site
|
echo ' # Fancy URLs';
|
||||||
echo ' location @postactiv {' >> $postactiv_nginx_site
|
echo ' location @postactiv {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $postactiv_nginx_site
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $postactiv_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $postactiv_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $postactiv_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '}' >> $postactiv_nginx_site
|
echo '}'; } >> "$postactiv_nginx_site"
|
||||||
else
|
else
|
||||||
echo -n '' > $postactiv_nginx_site
|
echo -n '' > "$postactiv_nginx_site"
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> $postactiv_nginx_site
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:$POSTACTIV_ONION_PORT default_server;" >> $postactiv_nginx_site
|
echo " listen 127.0.0.1:$POSTACTIV_ONION_PORT default_server;";
|
||||||
echo " server_name $POSTACTIV_ONION_HOSTNAME;" >> $postactiv_nginx_site
|
echo " server_name $POSTACTIV_ONION_HOSTNAME;";
|
||||||
echo '' >> $postactiv_nginx_site
|
echo ''; } >> "$postactiv_nginx_site"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $POSTACTIV_DOMAIN_NAME
|
nginx_disable_sniffing "$POSTACTIV_DOMAIN_NAME"
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '' >> "$postactiv_nginx_site"
|
||||||
function_check nginx_compress
|
function_check nginx_compress
|
||||||
nginx_compress $POSTACTIV_DOMAIN_NAME
|
nginx_compress "$POSTACTIV_DOMAIN_NAME"
|
||||||
echo '' >> $postactiv_nginx_site
|
{ echo '';
|
||||||
echo ' # Logs' >> $postactiv_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $postactiv_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $postactiv_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $postactiv_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$POSTACTIV_DOMAIN_NAME/htdocs;" >> $postactiv_nginx_site
|
echo " root /var/www/$POSTACTIV_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Index' >> $postactiv_nginx_site
|
echo ' # Index';
|
||||||
echo ' index index.php;' >> $postactiv_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # PHP' >> $postactiv_nginx_site
|
echo ' # PHP';
|
||||||
echo ' location ~ \.php {' >> $postactiv_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $postactiv_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $postactiv_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $postactiv_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $postactiv_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $postactiv_nginx_site
|
echo ' location / {'; } >> "$postactiv_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $POSTACTIV_DOMAIN_NAME '15m'
|
nginx_limits "$POSTACTIV_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @postactiv;' >> $postactiv_nginx_site
|
{ echo " try_files \$uri \$uri/ @postactiv;";
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Fancy URLs' >> $postactiv_nginx_site
|
echo ' # Fancy URLs';
|
||||||
echo ' location @postactiv {' >> $postactiv_nginx_site
|
echo ' location @postactiv {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> $postactiv_nginx_site
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '' >> $postactiv_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $postactiv_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $postactiv_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $postactiv_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $postactiv_nginx_site
|
echo ' }';
|
||||||
echo '}' >> $postactiv_nginx_site
|
echo '}'; } >> "$postactiv_nginx_site"
|
||||||
|
|
||||||
function_check configure_php
|
function_check configure_php
|
||||||
configure_php
|
configure_php
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate $POSTACTIV_DOMAIN_NAME 'yes'
|
create_site_certificate "$POSTACTIV_DOMAIN_NAME" 'yes'
|
||||||
|
|
||||||
# Ensure that the database gets backed up locally, if remote
|
# Ensure that the database gets backed up locally, if remote
|
||||||
# backups are not being used
|
# backups are not being used
|
||||||
|
@ -817,7 +820,7 @@ function install_postactiv_main {
|
||||||
backup_database_local postactiv
|
backup_database_local postactiv
|
||||||
|
|
||||||
function_check nginx_ensite
|
function_check nginx_ensite
|
||||||
nginx_ensite $POSTACTIV_DOMAIN_NAME
|
nginx_ensite "$POSTACTIV_DOMAIN_NAME"
|
||||||
|
|
||||||
# NOTE: For the typical case always enable SSL and only
|
# NOTE: For the typical case always enable SSL and only
|
||||||
# disable it if in onion only mode. This is due to complexities
|
# disable it if in onion only mode. This is due to complexities
|
||||||
|
@ -834,8 +837,8 @@ function install_postactiv_main {
|
||||||
|
|
||||||
# Create the configuration
|
# Create the configuration
|
||||||
postactiv_installer=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/scripts/install_cli.php
|
postactiv_installer=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/scripts/install_cli.php
|
||||||
if [ ! -f $postactiv_installer ]; then
|
if [ ! -f "$postactiv_installer" ]; then
|
||||||
rm -rf /var/www/$POSTACTIV_DOMAIN_NAME
|
rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
|
||||||
echo $'No postactiv commandline installer found'
|
echo $'No postactiv commandline installer found'
|
||||||
exit 53026
|
exit 53026
|
||||||
fi
|
fi
|
||||||
|
@ -856,45 +859,45 @@ function install_postactiv_main {
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
# check postactiv has a config file
|
# check postactiv has a config file
|
||||||
postactiv_config_file=/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/config.php
|
postactiv_config_file="/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/config.php"
|
||||||
if [ ! -f $postactiv_config_file ]; then
|
if [ ! -f "$postactiv_config_file" ]; then
|
||||||
drop_database postactiv
|
drop_database postactiv
|
||||||
rm -rf /var/www/$POSTACTIV_DOMAIN_NAME
|
rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
|
||||||
echo $'Postactiv config.php not found'
|
echo $'Postactiv config.php not found'
|
||||||
exit 87586
|
exit 87586
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some useful settings
|
# Some useful settings
|
||||||
if ! grep -q "Recommended postactiv settings" $postactiv_config_file; then
|
if ! grep -q "Recommended postactiv settings" "$postactiv_config_file"; then
|
||||||
echo "" >> $postactiv_config_file
|
{ echo "";
|
||||||
echo "// Recommended postactiv settings" >> $postactiv_config_file
|
echo "// Recommended postactiv settings";
|
||||||
echo "\$config['thumbnail']['maxsize'] = 3000;" >> $postactiv_config_file
|
echo "\$config['thumbnail']['maxsize'] = 3000;";
|
||||||
echo "\$config['profile']['delete'] = true;" >> $postactiv_config_file
|
echo "\$config['profile']['delete'] = true;";
|
||||||
echo "\$config['profile']['changenick'] = true;" >> $postactiv_config_file
|
echo "\$config['profile']['changenick'] = true;";
|
||||||
echo "\$config['public']['localonly'] = false;" >> $postactiv_config_file
|
echo "\$config['public']['localonly'] = false;";
|
||||||
echo "addPlugin('StoreRemoteMedia');" >> $postactiv_config_file
|
echo "addPlugin('StoreRemoteMedia');";
|
||||||
echo "\$config['queue']['enabled'] = true;" >> $postactiv_config_file
|
echo "\$config['queue']['enabled'] = true;";
|
||||||
echo "\$config['queue']['daemon'] = true;" >> $postactiv_config_file
|
echo "\$config['queue']['daemon'] = true;";
|
||||||
echo "\$config['ostatus']['hub_retries'] = 3;" >> $postactiv_config_file
|
echo "\$config['ostatus']['hub_retries'] = 3;"; } >> "$postactiv_config_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "\$config['mail']['domain'] = '${DEFAULT_DOMAIN_NAME}';" >> $postactiv_config_file
|
echo "\$config['mail']['domain'] = '${DEFAULT_DOMAIN_NAME}';" >> "$postactiv_config_file"
|
||||||
|
|
||||||
# This improves performance
|
# This improves performance
|
||||||
sed -i "s|//\$config\['db'\]\['schemacheck'\].*|\$config\['db'\]\['schemacheck'\] = 'script';|g" $postactiv_config_file
|
sed -i "s|//\$config\\['db'\\]\\['schemacheck'\\].*|\$config\\['db'\\]\\['schemacheck'\\] = 'script';|g" "$postactiv_config_file"
|
||||||
|
|
||||||
# remove the install script
|
# remove the install script
|
||||||
if [ -f /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php ]; then
|
if [ -f "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php" ]; then
|
||||||
rm /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php
|
rm "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/install.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl restart mariadb
|
systemctl restart mariadb
|
||||||
systemctl restart php7.0-fpm
|
systemctl restart php7.0-fpm
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$POSTACTIV_DOMAIN_NAME" -g postactiv --public no
|
"${PROJECT_NAME}-addemail" -u "$MY_USERNAME" -e "noreply@$POSTACTIV_DOMAIN_NAME" -g postactiv --public no
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a postactiv -p "$POSTACTIV_ADMIN_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a postactiv -p "$POSTACTIV_ADMIN_PASSWORD"
|
||||||
|
|
||||||
gnusocial_block_user_script
|
gnusocial_block_user_script
|
||||||
gnusocial_block_domain_script postactiv "$POSTACTIV_DOMAIN_NAME"
|
gnusocial_block_domain_script postactiv "$POSTACTIV_DOMAIN_NAME"
|
||||||
|
@ -905,7 +908,7 @@ function install_postactiv_main {
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_postactiv {
|
function install_postactiv {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -925,8 +928,8 @@ function install_postactiv {
|
||||||
install_nodejs pleroma-gnusocial
|
install_nodejs pleroma-gnusocial
|
||||||
install_pleroma_front_end "postactiv" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
|
install_pleroma_front_end "postactiv" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
|
||||||
install_gnusocial_default_background "postactiv" "$POSTACTIV_DOMAIN_NAME"
|
install_gnusocial_default_background "postactiv" "$POSTACTIV_DOMAIN_NAME"
|
||||||
postactiv_customise_logo
|
postactiv_customise_logo "$POSTACTIV_DOMAIN_NAME"
|
||||||
sed -i 's|"theme":.*|"theme": "base16-harmonic16-light.css",|g' /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static/config.json
|
sed -i 's|"theme":.*|"theme": "base16-harmonic16-light.css",|g' "/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static/config.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS"
|
expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS"
|
||||||
|
@ -940,8 +943,8 @@ function install_postactiv {
|
||||||
# And doesn't forget logins
|
# And doesn't forget logins
|
||||||
gnusocial_use_qvitter postactiv
|
gnusocial_use_qvitter postactiv
|
||||||
|
|
||||||
if [ $POSTACTIV_BACKGROUND_IMAGE_URL ]; then
|
if [ "$POSTACTIV_BACKGROUND_IMAGE_URL" ]; then
|
||||||
pleroma_set_background_image_from_url /var/www/$POSTACTIV_DOMAIN_NAME/htdocs "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
|
pleroma_set_background_image_from_url "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APP_INSTALLED=1
|
APP_INSTALLED=1
|
||||||
|
|
|
@ -56,7 +56,7 @@ function secure_privatebin {
|
||||||
find "${pbpath}/" -type d -print0 | xargs -0 chmod 0550
|
find "${pbpath}/" -type d -print0 | xargs -0 chmod 0550
|
||||||
|
|
||||||
chown -R ${rootuser}:${htgroup} "${pbpath}/"
|
chown -R ${rootuser}:${htgroup} "${pbpath}/"
|
||||||
chown -R www-data:www-data ${pbdata}
|
chown -R www-data:www-data "${pbdata}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function logging_on_privatebin {
|
function logging_on_privatebin {
|
||||||
|
@ -68,63 +68,65 @@ function logging_off_privatebin {
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_user_privatebin {
|
function remove_user_privatebin {
|
||||||
remove_username="$1"
|
echo -n ''
|
||||||
|
# remove_username="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_user_privatebin {
|
function add_user_privatebin {
|
||||||
new_username="$1"
|
# new_username="$1"
|
||||||
new_user_password="$2"
|
# new_user_password="$2"
|
||||||
|
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_interactive_privatebin {
|
function install_interactive_privatebin {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $ONION_ONLY != "no" ]]; then
|
if [[ "$ONION_ONLY" != "no" ]]; then
|
||||||
PRIVATEBIN_DOMAIN_NAME='privatebin.local'
|
PRIVATEBIN_DOMAIN_NAME='privatebin.local'
|
||||||
else
|
else
|
||||||
PRIVATEBIN_DETAILS_COMPLETE=
|
PRIVATEBIN_DETAILS_COMPLETE=
|
||||||
while [ ! $PRIVATEBIN_DETAILS_COMPLETE ]
|
while [ ! $PRIVATEBIN_DETAILS_COMPLETE ]
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"PrivateBin Configuration" \
|
--title $"PrivateBin Configuration" \
|
||||||
--form $"\nPlease enter your PrivateBin details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
--form $"\\nPlease enter your PrivateBin details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'PRIVATEBIN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 33 40 \
|
$"Domain:" 1 1 "$(grep 'PRIVATEBIN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 33 40 \
|
||||||
$"Code:" 2 1 "$(grep 'PRIVATEBIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 33 255 \
|
$"Code:" 2 1 "$(grep 'PRIVATEBIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 33 255 \
|
||||||
2> $data
|
2> "$data"
|
||||||
else
|
else
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"PrivateBin Configuration" \
|
--title $"PrivateBin Configuration" \
|
||||||
--form $"\nPlease enter your PrivateBin details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
--form $"\\nPlease enter your PrivateBin details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'PRIVATEBIN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 33 40 \
|
$"Domain:" 1 1 "$(grep 'PRIVATEBIN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 33 40 \
|
||||||
2> $data
|
2> "$data"
|
||||||
fi
|
fi
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) rm -f "$data"
|
||||||
255) exit 1;;
|
exit 1;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
PRIVATEBIN_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
PRIVATEBIN_DOMAIN_NAME=$(sed -n 1p < "$data")
|
||||||
if [ $PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ "$PRIVATEBIN_DOMAIN_NAME" ]; then
|
||||||
if [[ $PRIVATEBIN_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
if [[ "$PRIVATEBIN_DOMAIN_NAME" == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
||||||
PRIVATEBIN_DOMAIN_NAME=""
|
PRIVATEBIN_DOMAIN_NAME=""
|
||||||
fi
|
fi
|
||||||
TEST_DOMAIN_NAME=$PRIVATEBIN_DOMAIN_NAME
|
TEST_DOMAIN_NAME=$PRIVATEBIN_DOMAIN_NAME
|
||||||
validate_domain_name
|
validate_domain_name
|
||||||
if [[ $TEST_DOMAIN_NAME != $PRIVATEBIN_DOMAIN_NAME ]]; then
|
if [[ "$TEST_DOMAIN_NAME" != "$PRIVATEBIN_DOMAIN_NAME" ]]; then
|
||||||
PRIVATEBIN_DOMAIN_NAME=
|
PRIVATEBIN_DOMAIN_NAME=
|
||||||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||||||
else
|
else
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
PRIVATEBIN_CODE=$(cat $data | sed -n 2p)
|
PRIVATEBIN_CODE=$(sed -n 2p < "$data")
|
||||||
validate_freedns_code "$PRIVATEBIN_CODE"
|
validate_freedns_code "$PRIVATEBIN_CODE"
|
||||||
if [ ! $VALID_CODE ]; then
|
if [ ! "$VALID_CODE" ]; then
|
||||||
PRIVATEBIN_DOMAIN_NAME=
|
PRIVATEBIN_DOMAIN_NAME=
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -133,6 +135,7 @@ function install_interactive_privatebin {
|
||||||
if [ $PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ $PRIVATEBIN_DOMAIN_NAME ]; then
|
||||||
PRIVATEBIN_DETAILS_COMPLETE="yes"
|
PRIVATEBIN_DETAILS_COMPLETE="yes"
|
||||||
fi
|
fi
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
|
|
||||||
write_config_param "PRIVATEBIN_CODE" "$PRIVATEBIN_CODE"
|
write_config_param "PRIVATEBIN_CODE" "$PRIVATEBIN_CODE"
|
||||||
|
@ -142,8 +145,9 @@ function install_interactive_privatebin {
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_password_privatebin {
|
function change_password_privatebin {
|
||||||
curr_username="$1"
|
# curr_username="$1"
|
||||||
new_user_password="$2"
|
# new_user_password="$2"
|
||||||
|
echo -n ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function reconfigure_privatebin {
|
function reconfigure_privatebin {
|
||||||
|
@ -156,13 +160,13 @@ function upgrade_privatebin {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "privatebin domain" $COMPLETION_FILE; then
|
if grep -q "privatebin domain" "$COMPLETION_FILE"; then
|
||||||
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update to the next commit
|
# update to the next commit
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs "privatebin commit" "$PRIVATEBIN_COMMIT" $PRIVATEBIN_REPO
|
set_repo_commit "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs" "privatebin commit" "$PRIVATEBIN_COMMIT" "$PRIVATEBIN_REPO"
|
||||||
|
|
||||||
secure_privatebin
|
secure_privatebin
|
||||||
}
|
}
|
||||||
|
@ -170,40 +174,40 @@ function upgrade_privatebin {
|
||||||
|
|
||||||
function backup_local_privatebin {
|
function backup_local_privatebin {
|
||||||
PRIVATEBIN_DOMAIN_NAME='privatebin'
|
PRIVATEBIN_DOMAIN_NAME='privatebin'
|
||||||
if grep -q "privatebin domain" $COMPLETION_FILE; then
|
if grep -q "privatebin domain" "$COMPLETION_FILE"; then
|
||||||
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source_directory=/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data
|
source_directory="/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data"
|
||||||
|
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${PRIVATEBIN_DOMAIN_NAME}
|
suspend_site "${PRIVATEBIN_DOMAIN_NAME}"
|
||||||
|
|
||||||
function_check backup_directory_to_usb
|
function_check backup_directory_to_usb
|
||||||
dest_directory=privatebin
|
dest_directory=privatebin
|
||||||
backup_directory_to_usb $source_directory $dest_directory
|
backup_directory_to_usb "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
function_check restart_site
|
function_check restart_site
|
||||||
restart_site
|
restart_site
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_local_privatebin {
|
function restore_local_privatebin {
|
||||||
if ! grep -q "privatebin domain" $COMPLETION_FILE; then
|
if ! grep -q "privatebin domain" "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
||||||
if [ $PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ "$PRIVATEBIN_DOMAIN_NAME" ]; then
|
||||||
echo $"Restoring privatebin"
|
echo $"Restoring privatebin"
|
||||||
temp_restore_dir=/root/tempprivatebin
|
temp_restore_dir=/root/tempprivatebin
|
||||||
privatebin_dir=/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data
|
privatebin_dir="/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data"
|
||||||
|
|
||||||
function_check restore_directory_from_usb
|
function_check restore_directory_from_usb
|
||||||
restore_directory_from_usb $temp_restore_dir privatebin
|
restore_directory_from_usb $temp_restore_dir privatebin
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
if [ -d cp $temp_restore_dir$privatebin_dir ]; then
|
if [ -d "$temp_restore_dir$privatebin_dir" ]; then
|
||||||
cp -rp $temp_restore_dir$privatebin_dir/* $privatebin_dir/
|
cp -rp "$temp_restore_dir$privatebin_dir/*" "$privatebin_dir/"
|
||||||
else
|
else
|
||||||
cp -rp $temp_restore_dir/* $privatebin_dir/
|
cp -rp "$temp_restore_dir/*" "$privatebin_dir/"
|
||||||
fi
|
fi
|
||||||
secure_privatebin
|
secure_privatebin
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
|
@ -215,39 +219,39 @@ function restore_local_privatebin {
|
||||||
|
|
||||||
function backup_remote_privatebin {
|
function backup_remote_privatebin {
|
||||||
PRIVATEBIN_DOMAIN_NAME='privatebin'
|
PRIVATEBIN_DOMAIN_NAME='privatebin'
|
||||||
if grep -q "privatebin domain" $COMPLETION_FILE; then
|
if grep -q "privatebin domain" "$COMPLETION_FILE"; then
|
||||||
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source_directory=/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data
|
source_directory="/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data"
|
||||||
|
|
||||||
function_check suspend_site
|
function_check suspend_site
|
||||||
suspend_site ${PRIVATEBIN_DOMAIN_NAME}
|
suspend_site "${PRIVATEBIN_DOMAIN_NAME}"
|
||||||
|
|
||||||
function_check backup_directory_to_friend
|
function_check backup_directory_to_friend
|
||||||
dest_directory=privatebin
|
dest_directory=privatebin
|
||||||
backup_directory_to_friend $source_directory $dest_directory
|
backup_directory_to_friend "$source_directory" "$dest_directory"
|
||||||
|
|
||||||
function_check restart_site
|
function_check restart_site
|
||||||
restart_site
|
restart_site
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore_remote_privatebin {
|
function restore_remote_privatebin {
|
||||||
if ! grep -q "privatebin domain" $COMPLETION_FILE; then
|
if ! grep -q "privatebin domain" "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
PRIVATEBIN_DOMAIN_NAME=$(get_completion_param "privatebin domain")
|
||||||
if [ $PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ "$PRIVATEBIN_DOMAIN_NAME" ]; then
|
||||||
temp_restore_dir=/root/tempprivatebin
|
temp_restore_dir=/root/tempprivatebin
|
||||||
privatebin_dir=/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data
|
privatebin_dir=/var/www/${PRIVATEBIN_DOMAIN_NAME}/htdocs/data
|
||||||
|
|
||||||
function_check restore_directory_from_friend
|
function_check restore_directory_from_friend
|
||||||
restore_directory_from_friend $temp_restore_dir privatebin
|
restore_directory_from_friend $temp_restore_dir privatebin
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
if [ -d cp $temp_restore_dir$privatebin_dir ]; then
|
if [ -d "$temp_restore_dir$privatebin_dir" ]; then
|
||||||
cp -rp $temp_restore_dir$privatebin_dir/* $privatebin_dir/
|
cp -rp "$temp_restore_dir$privatebin_dir/*" "$privatebin_dir/"
|
||||||
else
|
else
|
||||||
cp -rp $temp_restore_dir/* $privatebin_dir/
|
cp -rp "$temp_restore_dir/*" "$privatebin_dir/"
|
||||||
fi
|
fi
|
||||||
secure_privatebin
|
secure_privatebin
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
|
@ -262,14 +266,14 @@ function remove_privatebin {
|
||||||
read_config_param "PRIVATEBIN_DOMAIN_NAME"
|
read_config_param "PRIVATEBIN_DOMAIN_NAME"
|
||||||
read_config_param "MY_USERNAME"
|
read_config_param "MY_USERNAME"
|
||||||
echo "Removing $PRIVATEBIN_DOMAIN_NAME"
|
echo "Removing $PRIVATEBIN_DOMAIN_NAME"
|
||||||
nginx_dissite $PRIVATEBIN_DOMAIN_NAME
|
nginx_dissite "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
remove_certs $PRIVATEBIN_DOMAIN_NAME
|
remove_certs "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
|
|
||||||
if [ -d /var/www/$PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ -d "/var/www/$PRIVATEBIN_DOMAIN_NAME" ]; then
|
||||||
rm -rf /var/www/$PRIVATEBIN_DOMAIN_NAME
|
rm -rf "/var/www/$PRIVATEBIN_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ -f /etc/nginx/sites-available/$PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ -f "/etc/nginx/sites-available/$PRIVATEBIN_DOMAIN_NAME" ]; then
|
||||||
rm /etc/nginx/sites-available/$PRIVATEBIN_DOMAIN_NAME
|
rm "/etc/nginx/sites-available/$PRIVATEBIN_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
function_check remove_onion_service
|
function_check remove_onion_service
|
||||||
remove_onion_service privatebin ${PRIVATEBIN_ONION_PORT}
|
remove_onion_service privatebin ${PRIVATEBIN_ONION_PORT}
|
||||||
|
@ -278,18 +282,18 @@ function remove_privatebin {
|
||||||
fi
|
fi
|
||||||
remove_app privatebin
|
remove_app privatebin
|
||||||
remove_completion_param install_privatebin
|
remove_completion_param install_privatebin
|
||||||
sed -i '/privatebin/d' $COMPLETION_FILE
|
sed -i '/privatebin/d' "$COMPLETION_FILE"
|
||||||
|
|
||||||
function_check remove_ddns_domain
|
function_check remove_ddns_domain
|
||||||
remove_ddns_domain $PRIVATEBIN_DOMAIN_NAME
|
remove_ddns_domain "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_privatebin {
|
function install_privatebin {
|
||||||
if [ ! $ONION_ONLY ]; then
|
if [ ! "$ONION_ONLY" ]; then
|
||||||
ONION_ONLY='no'
|
ONION_ONLY='no'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ ! "$PRIVATEBIN_DOMAIN_NAME" ]; then
|
||||||
echo $'No domain name was given for privatebin'
|
echo $'No domain name was given for privatebin'
|
||||||
exit 7359
|
exit 7359
|
||||||
fi
|
fi
|
||||||
|
@ -298,153 +302,153 @@ function install_privatebin {
|
||||||
apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
|
apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
|
||||||
apt-get -yq install php-libsodium libsodium18 php-mcrypt
|
apt-get -yq install php-libsodium libsodium18 php-mcrypt
|
||||||
|
|
||||||
if [ ! -d /var/www/$PRIVATEBIN_DOMAIN_NAME ]; then
|
if [ ! -d "/var/www/$PRIVATEBIN_DOMAIN_NAME" ]; then
|
||||||
mkdir /var/www/$PRIVATEBIN_DOMAIN_NAME
|
mkdir "/var/www/$PRIVATEBIN_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
if [ ! -d /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs" ]; then
|
||||||
|
|
||||||
if [ -d /repos/privatebin ]; then
|
if [ -d /repos/privatebin ]; then
|
||||||
mkdir /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs
|
mkdir "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs"
|
||||||
cp -r -p /repos/privatebin/. /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs
|
cp -r -p /repos/privatebin/. "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs"
|
||||||
cd /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs
|
cd "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs" || exit 3468246824
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
git_clone $PRIVATEBIN_REPO /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs
|
git_clone "$PRIVATEBIN_REPO" "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs ]; then
|
if [ ! -d "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs" ]; then
|
||||||
echo $'Unable to clone privatebin repo'
|
echo $'Unable to clone privatebin repo'
|
||||||
exit 63763873
|
exit 63763873
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs
|
cd "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs" || exit 24682462
|
||||||
git checkout $PRIVATEBIN_COMMIT -b $PRIVATEBIN_COMMIT
|
git checkout "$PRIVATEBIN_COMMIT" -b "$PRIVATEBIN_COMMIT"
|
||||||
set_completion_param "privatebin commit" "$PRIVATEBIN_COMMIT"
|
set_completion_param "privatebin commit" "$PRIVATEBIN_COMMIT"
|
||||||
|
|
||||||
chmod g+w /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs
|
chmod g+w "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs"
|
||||||
chown -R www-data:www-data /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs
|
chown -R www-data:www-data "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs"
|
||||||
|
|
||||||
function_check add_ddns_domain
|
function_check add_ddns_domain
|
||||||
add_ddns_domain $PRIVATEBIN_DOMAIN_NAME
|
add_ddns_domain "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
|
|
||||||
PRIVATEBIN_ONION_HOSTNAME=$(add_onion_service privatebin 80 ${PRIVATEBIN_ONION_PORT})
|
PRIVATEBIN_ONION_HOSTNAME=$(add_onion_service privatebin 80 ${PRIVATEBIN_ONION_PORT})
|
||||||
|
|
||||||
privatebin_nginx_site=/etc/nginx/sites-available/$PRIVATEBIN_DOMAIN_NAME
|
privatebin_nginx_site=/etc/nginx/sites-available/$PRIVATEBIN_DOMAIN_NAME
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $PRIVATEBIN_DOMAIN_NAME "index index.php"
|
nginx_http_redirect "$PRIVATEBIN_DOMAIN_NAME" "index index.php"
|
||||||
echo 'server {' >> $privatebin_nginx_site
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> $privatebin_nginx_site
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> $privatebin_nginx_site
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo " server_name $PRIVATEBIN_DOMAIN_NAME;" >> $privatebin_nginx_site
|
echo " server_name $PRIVATEBIN_DOMAIN_NAME;";
|
||||||
echo '' >> $privatebin_nginx_site
|
echo ''; } >> "$privatebin_nginx_site"
|
||||||
function_check nginx_compress
|
function_check nginx_compress
|
||||||
nginx_compress $PRIVATEBIN_DOMAIN_NAME
|
nginx_compress "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '' >> "$privatebin_nginx_site"
|
||||||
echo ' # Security' >> $privatebin_nginx_site
|
echo ' # Security' >> "$privatebin_nginx_site"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $PRIVATEBIN_DOMAIN_NAME
|
nginx_ssl "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
|
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $PRIVATEBIN_DOMAIN_NAME
|
nginx_disable_sniffing "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
|
|
||||||
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $privatebin_nginx_site
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' # Logs' >> $privatebin_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $privatebin_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $privatebin_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo " root /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs;" >> $privatebin_nginx_site
|
echo " root /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' index index.php;' >> $privatebin_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' location ~ \.php {' >> $privatebin_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $privatebin_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $privatebin_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $privatebin_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $privatebin_nginx_site
|
echo ' }';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $privatebin_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $privatebin_nginx_site
|
echo ' location / {'; } >> "$privatebin_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $PRIVATEBIN_DOMAIN_NAME '15m'
|
nginx_limits "$PRIVATEBIN_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @privatebin;' >> $privatebin_nginx_site
|
{ echo ' try_files $uri $uri/ @privatebin;';
|
||||||
echo ' }' >> $privatebin_nginx_site
|
echo ' }';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $privatebin_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $privatebin_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $privatebin_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $privatebin_nginx_site
|
echo ' }';
|
||||||
echo '}' >> $privatebin_nginx_site
|
echo '}';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo ''; } >> "$privatebin_nginx_site"
|
||||||
else
|
else
|
||||||
echo -n '' > $privatebin_nginx_site
|
echo -n '' > "$privatebin_nginx_site"
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> $privatebin_nginx_site
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:$PRIVATEBIN_ONION_PORT default_server;" >> $privatebin_nginx_site
|
echo " listen 127.0.0.1:$PRIVATEBIN_ONION_PORT default_server;";
|
||||||
echo " server_name $PRIVATEBIN_ONION_HOSTNAME;" >> $privatebin_nginx_site
|
echo " server_name $PRIVATEBIN_ONION_HOSTNAME;";
|
||||||
echo '' >> $privatebin_nginx_site
|
echo ''; } >> "$privatebin_nginx_site"
|
||||||
function_check nginx_compress
|
function_check nginx_compress
|
||||||
nginx_compress $PRIVATEBIN_DOMAIN_NAME
|
nginx_compress "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '' >> "$privatebin_nginx_site"
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $PRIVATEBIN_DOMAIN_NAME
|
nginx_disable_sniffing "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
echo '' >> $privatebin_nginx_site
|
{ echo '';
|
||||||
echo ' # Logs' >> $privatebin_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $privatebin_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $privatebin_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo " root /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs;" >> $privatebin_nginx_site
|
echo " root /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' index index.php;' >> $privatebin_nginx_site
|
echo ' index index.php;';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' location ~ \.php {' >> $privatebin_nginx_site
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> $privatebin_nginx_site
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> $privatebin_nginx_site
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> $privatebin_nginx_site
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> $privatebin_nginx_site
|
echo ' }';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' # Location' >> $privatebin_nginx_site
|
echo ' # Location';
|
||||||
echo ' location / {' >> $privatebin_nginx_site
|
echo ' location / {'; } >> "$privatebin_nginx_site"
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $PRIVATEBIN_DOMAIN_NAME '15m'
|
nginx_limits "$PRIVATEBIN_DOMAIN_NAME" '15m'
|
||||||
echo ' try_files $uri $uri/ @privatebin;' >> $privatebin_nginx_site
|
{ echo ' try_files $uri $uri/ @privatebin;';
|
||||||
echo ' }' >> $privatebin_nginx_site
|
echo ' }';
|
||||||
echo '' >> $privatebin_nginx_site
|
echo '';
|
||||||
echo ' # Restrict access that is unnecessary anyway' >> $privatebin_nginx_site
|
echo ' # Restrict access that is unnecessary anyway';
|
||||||
echo ' location ~ /\.(ht|git) {' >> $privatebin_nginx_site
|
echo ' location ~ /\.(ht|git) {';
|
||||||
echo ' deny all;' >> $privatebin_nginx_site
|
echo ' deny all;';
|
||||||
echo ' }' >> $privatebin_nginx_site
|
echo ' }';
|
||||||
echo '}' >> $privatebin_nginx_site
|
echo '}'; } >> "$privatebin_nginx_site"
|
||||||
|
|
||||||
function_check configure_php
|
function_check configure_php
|
||||||
configure_php
|
configure_php
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
create_site_certificate $PRIVATEBIN_DOMAIN_NAME 'yes'
|
create_site_certificate "$PRIVATEBIN_DOMAIN_NAME" 'yes'
|
||||||
|
|
||||||
function_check nginx_ensite
|
function_check nginx_ensite
|
||||||
nginx_ensite $PRIVATEBIN_DOMAIN_NAME
|
nginx_ensite "$PRIVATEBIN_DOMAIN_NAME"
|
||||||
|
|
||||||
cp /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.sample.php /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
cp "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.sample.php" "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
|
|
||||||
# Change some defaults
|
# Change some defaults
|
||||||
sed -i 's|; qrcode|qrcode|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|; qrcode|qrcode|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|default =.*|default = "1day"|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|default =.*|default = "1day"|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|languagedefault =.*|languagedefault = "en"|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|languagedefault =.*|languagedefault = "en"|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|1week =|; 1week =|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|1week =|; 1week =|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|1month =|; 1month =|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|1month =|; 1month =|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|1year =|; 1year =|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|1year =|; 1year =|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|never =|; never =|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|never =|; never =|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|limit = 10|limit = 30|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|limit = 10|limit = 30|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|limit = 300|limit = 0|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|limit = 300|limit = 0|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|batchsize =.*|batchsize = 100|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|batchsize =.*|batchsize = 100|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|sizelimit =.*|sizelimit = 32768|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|sizelimit =.*|sizelimit = 32768|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
sed -i 's|defaultformatter =.*|defaultformatter = "markdown"|g' /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php
|
sed -i 's|defaultformatter =.*|defaultformatter = "markdown"|g' "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/cfg/conf.php"
|
||||||
|
|
||||||
mkdir -p /var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/data
|
mkdir -p "/var/www/$PRIVATEBIN_DOMAIN_NAME/htdocs/data"
|
||||||
|
|
||||||
secure_privatebin
|
secure_privatebin
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,13 @@ function logging_off_profanity {
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_user_profanity {
|
function remove_user_profanity {
|
||||||
remove_username="$1"
|
echo -n ''
|
||||||
|
# remove_username="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_user_profanity {
|
function add_user_profanity {
|
||||||
new_username="$1"
|
# new_username="$1"
|
||||||
new_user_password="$2"
|
# new_user_password="$2"
|
||||||
|
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
@ -82,19 +83,19 @@ function change_password_profanity {
|
||||||
|
|
||||||
read_config_param DEFAULT_DOMAIN_NAME
|
read_config_param DEFAULT_DOMAIN_NAME
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $curr_username -a xmpp -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a xmpp -p "$new_user_password"
|
||||||
|
|
||||||
# TODO: this is currently interactive. Really there needs to be a
|
# TODO: this is currently interactive. Really there needs to be a
|
||||||
# non-interactive password change option for prosodyctl
|
# non-interactive password change option for prosodyctl
|
||||||
clear
|
clear
|
||||||
echo ''
|
echo ''
|
||||||
echo $'Currently Prosody requires password changes to be done interactively'
|
echo $'Currently Prosody requires password changes to be done interactively'
|
||||||
prosodyctl passwd ${curr_username}@${DEFAULT_DOMAIN_NAME}
|
prosodyctl passwd "${curr_username}@${DEFAULT_DOMAIN_NAME}"
|
||||||
|
|
||||||
XMPP_CLIENT_DIR=/home/$curr_username/.local/share/profanity
|
XMPP_CLIENT_DIR=/home/$curr_username/.local/share/profanity
|
||||||
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
||||||
if [ -f $XMPP_CLIENT_ACCOUNTS ]; then
|
if [ -f "$XMPP_CLIENT_ACCOUNTS" ]; then
|
||||||
sed -i "s|password=.*|password=$new_user_password|g" $XMPP_CLIENT_ACCOUNTS
|
sed -i "s|password=.*|password=$new_user_password|g" "$XMPP_CLIENT_ACCOUNTS"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,11 +111,11 @@ function upgrade_profanity {
|
||||||
|
|
||||||
rm -rf /tmp/*
|
rm -rf /tmp/*
|
||||||
|
|
||||||
CURR_LIBMESODE_COMMIT=$(cat $COMPLETION_FILE | grep "libmesode commit" | awk -F ':' '{print $2}')
|
CURR_LIBMESODE_COMMIT=$(grep "libmesode commit" "$COMPLETION_FILE" | awk -F ':' '{print $2}')
|
||||||
if [[ "$CURR_LIBMESODE_COMMIT" != "$LIBMESODE_COMMIT" ]]; then
|
if [[ "$CURR_LIBMESODE_COMMIT" != "$LIBMESODE_COMMIT" ]]; then
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit $INSTALL_DIR/libmesode "libmesode commit" "$LIBMESODE_COMMIT" $LIBMESODE_REPO
|
set_repo_commit "$INSTALL_DIR/libmesode" "libmesode commit" "$LIBMESODE_COMMIT" $LIBMESODE_REPO
|
||||||
cd $INSTALL_DIR/libmesode
|
cd "$INSTALL_DIR/libmesode" || exit 42682682
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
./configure
|
./configure
|
||||||
make
|
make
|
||||||
|
@ -124,42 +125,42 @@ function upgrade_profanity {
|
||||||
|
|
||||||
rm -rf /tmp/*
|
rm -rf /tmp/*
|
||||||
|
|
||||||
CURR_PROFANITY_COMMIT=$(cat $COMPLETION_FILE | grep "profanity commit" | awk -F ':' '{print $2}')
|
CURR_PROFANITY_COMMIT=$(grep "profanity commit" "$COMPLETION_FILE" | awk -F ':' '{print $2}')
|
||||||
if [[ "$CURR_PROFANITY_COMMIT" != "$PROFANITY_COMMIT" ]]; then
|
if [[ "$CURR_PROFANITY_COMMIT" != "$PROFANITY_COMMIT" ]]; then
|
||||||
function_check set_repo_commit
|
function_check set_repo_commit
|
||||||
set_repo_commit $INSTALL_DIR/profanity "profanity commit" "$PROFANITY_COMMIT" $PROFANITY_REPO
|
set_repo_commit "$INSTALL_DIR/profanity" "profanity commit" "$PROFANITY_COMMIT" $PROFANITY_REPO
|
||||||
cd $INSTALL_DIR/profanity
|
cd "$INSTALL_DIR/profanity" || exit 248242684
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
|
./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CURR_PROFANITY_OMEMO_PLUGIN_COMMIT=$(cat $COMPLETION_FILE | grep "profanity omemo plugin commit" | awk -F ':' '{print $2}')
|
CURR_PROFANITY_OMEMO_PLUGIN_COMMIT=$(grep "profanity omemo plugin commit" "$COMPLETION_FILE" | awk -F ':' '{print $2}')
|
||||||
if [[ "$CURR_PROFANITY_OMEMO_PLUGIN_COMMIT" != "$PROFANITY_OMEMO_PLUGIN_COMMIT" ]]; then
|
if [[ "$CURR_PROFANITY_OMEMO_PLUGIN_COMMIT" != "$PROFANITY_OMEMO_PLUGIN_COMMIT" ]]; then
|
||||||
# upgrade omemo plugins for all users
|
# upgrade omemo plugins for all users
|
||||||
set_repo_commit $INSTALL_DIR/profanity-omemo-plugin "profanity omemo plugin commit" "$PROFANITY_OMEMO_PLUGIN_COMMIT" $PROFANITY_OMEMO_PLUGIN_REPO
|
set_repo_commit "$INSTALL_DIR/profanity-omemo-plugin" "profanity omemo plugin commit" "$PROFANITY_OMEMO_PLUGIN_COMMIT" $PROFANITY_OMEMO_PLUGIN_REPO
|
||||||
cd $INSTALL_DIR/profanity-omemo-plugin
|
cd "$INSTALL_DIR/profanity-omemo-plugin" || exit 2468246284
|
||||||
sed -i 's|python setup.py|python2.7 setup.py|g' $INSTALL_DIR/profanity-omemo-plugin/install.sh
|
sed -i 's|python setup.py|python2.7 setup.py|g' "$INSTALL_DIR/profanity-omemo-plugin/install.sh"
|
||||||
pip uninstall -y profanity-omemo-plugin
|
pip uninstall -y profanity-omemo-plugin
|
||||||
./install.sh
|
./install.sh
|
||||||
for d in /home/*/ ; do
|
for d in /home/*/ ; do
|
||||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||||
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
||||||
if [ ! -d /home/$USERNAME/.local/share/profanity/plugins ]; then
|
if [ ! -d "/home/$USERNAME/.local/share/profanity/plugins" ]; then
|
||||||
mkdir -p /home/$USERNAME/.local/share/profanity/plugins
|
mkdir -p "/home/$USERNAME/.local/share/profanity/plugins"
|
||||||
fi
|
fi
|
||||||
if [ -f $INSTALL_DIR/profanity-omemo-plugin/omemo.py ]; then
|
if [ -f "$INSTALL_DIR/profanity-omemo-plugin/omemo.py" ]; then
|
||||||
rm $INSTALL_DIR/profanity-omemo-plugin/omemo.*
|
rm "$INSTALL_DIR/profanity-omemo-plugin/omemo.*"
|
||||||
fi
|
fi
|
||||||
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /home/$USERNAME/.local/share/profanity/plugins
|
cp "$INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py" "/home/$USERNAME/.local/share/profanity/plugins"
|
||||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.local
|
chown -R "$USERNAME":"$USERNAME" "/home/$USERNAME/.local"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -f /etc/skel/.local/share/profanity/plugins/omemo.py ]; then
|
if [ -f /etc/skel/.local/share/profanity/plugins/omemo.py ]; then
|
||||||
rm /etc/skel/.local/share/profanity/plugins/omemo.*
|
rm /etc/skel/.local/share/profanity/plugins/omemo.*
|
||||||
fi
|
fi
|
||||||
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /etc/skel/.local/share/profanity/plugins
|
cp "$INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py" "/etc/skel/.local/share/profanity/plugins"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
|
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
|
||||||
|
@ -183,11 +184,11 @@ function restore_remote_profanity {
|
||||||
|
|
||||||
function remove_profanity {
|
function remove_profanity {
|
||||||
if [ -f /usr/local/bin/profanity ]; then
|
if [ -f /usr/local/bin/profanity ]; then
|
||||||
cd $INSTALL_DIR/profanity
|
cd "$INSTALL_DIR/profanity" || exit 4628462848
|
||||||
make uninstall
|
make uninstall
|
||||||
|
|
||||||
remove_completion_param install_profanity
|
remove_completion_param install_profanity
|
||||||
sed -i '/profanity/d' $COMPLETION_FILE
|
sed -i '/profanity/d' "$COMPLETION_FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +198,8 @@ function install_profanity {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# install profanity from source in order to get OMEMO support
|
# install profanity from source in order to get OMEMO support
|
||||||
if [ ! -d $INSTALL_DIR ]; then
|
if [ ! -d "$INSTALL_DIR" ]; then
|
||||||
mkdir -p $INSTALL_DIR
|
mkdir -p "$INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
apt-get -yq install automake autoconf autoconf-archive libtool build-essential
|
apt-get -yq install automake autoconf autoconf-archive libtool build-essential
|
||||||
|
@ -207,15 +208,15 @@ function install_profanity {
|
||||||
|
|
||||||
# dependency for profanity not available in debian
|
# dependency for profanity not available in debian
|
||||||
if [ -d /repos/libmesode ]; then
|
if [ -d /repos/libmesode ]; then
|
||||||
mkdir $INSTALL_DIR/libmesode
|
mkdir "$INSTALL_DIR/libmesode"
|
||||||
cp -r -p /repos/libmesode/. $INSTALL_DIR/libmesode
|
cp -r -p /repos/libmesode/. "$INSTALL_DIR/libmesode"
|
||||||
cd $INSTALL_DIR/libmesode
|
cd "$INSTALL_DIR/libmesode" || exit 46287642846872
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
git_clone $LIBMESODE_REPO $INSTALL_DIR/libmesode
|
git_clone "$LIBMESODE_REPO" "$INSTALL_DIR/libmesode"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $INSTALL_DIR/libmesode
|
cd "$INSTALL_DIR/libmesode" || exit 2468246284
|
||||||
git checkout $LIBMESODE_COMMIT -b $LIBMESODE_COMMIT
|
git checkout $LIBMESODE_COMMIT -b $LIBMESODE_COMMIT
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
./configure
|
./configure
|
||||||
|
@ -225,15 +226,15 @@ function install_profanity {
|
||||||
|
|
||||||
# build profanity
|
# build profanity
|
||||||
if [ -d /repos/profanity ]; then
|
if [ -d /repos/profanity ]; then
|
||||||
mkdir $INSTALL_DIR/profanity
|
mkdir "$INSTALL_DIR/profanity"
|
||||||
cp -r -p /repos/profanity/. $INSTALL_DIR/profanity
|
cp -r -p /repos/profanity/. "$INSTALL_DIR/profanity"
|
||||||
cd $INSTALL_DIR/profanity
|
cd "$INSTALL_DIR/profanity" || exit 2468246824
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
git_clone $PROFANITY_REPO $INSTALL_DIR/profanity
|
git_clone "$PROFANITY_REPO" "$INSTALL_DIR/profanity"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $INSTALL_DIR/profanity
|
cd "$INSTALL_DIR/profanity" || exit 54287452858
|
||||||
git checkout $PROFANITY_COMMIT -b $PROFANITY_COMMIT
|
git checkout $PROFANITY_COMMIT -b $PROFANITY_COMMIT
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
|
./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
|
||||||
|
@ -249,116 +250,116 @@ function install_profanity {
|
||||||
apt-get -yq install python-pip python-setuptools clang libffi-dev libssl-dev python-dev
|
apt-get -yq install python-pip python-setuptools clang libffi-dev libssl-dev python-dev
|
||||||
|
|
||||||
if [ -d /repos/profanity-omemo ]; then
|
if [ -d /repos/profanity-omemo ]; then
|
||||||
mkdir $INSTALL_DIR/profanity-omemo-plugin
|
mkdir "$INSTALL_DIR/profanity-omemo-plugin"
|
||||||
cp -r -p /repos/profanity-omemo/. $INSTALL_DIR/profanity-omemo-plugin
|
cp -r -p /repos/profanity-omemo/. "$INSTALL_DIR/profanity-omemo-plugin"
|
||||||
cd $INSTALL_DIR/profanity-omemo-plugin
|
cd "$INSTALL_DIR/profanity-omemo-plugin" || exit 24682462842
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
git_clone $PROFANITY_OMEMO_PLUGIN_REPO $INSTALL_DIR/profanity-omemo-plugin
|
git_clone "$PROFANITY_OMEMO_PLUGIN_REPO" "$INSTALL_DIR/profanity-omemo-plugin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $INSTALL_DIR/profanity-omemo-plugin
|
cd "$INSTALL_DIR/profanity-omemo-plugin" || exit 6428468248
|
||||||
git checkout $PROFANITY_OMEMO_PLUGIN_COMMIT -b $PROFANITY_OMEMO_PLUGIN_COMMIT
|
git checkout $PROFANITY_OMEMO_PLUGIN_COMMIT -b $PROFANITY_OMEMO_PLUGIN_COMMIT
|
||||||
if [ ! -f $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py ]; then
|
if [ ! -f "$INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py" ]; then
|
||||||
echo $'prof_omemo_plugin.py not found'
|
echo $'prof_omemo_plugin.py not found'
|
||||||
exit 389225
|
exit 389225
|
||||||
fi
|
fi
|
||||||
sed -i 's|python setup.py|python2.7 setup.py|g' $INSTALL_DIR/profanity-omemo-plugin/install.sh
|
sed -i 's|python setup.py|python2.7 setup.py|g' "$INSTALL_DIR/profanity-omemo-plugin/install.sh"
|
||||||
./install.sh
|
./install.sh
|
||||||
|
|
||||||
mkdir -p /etc/skel/.local/share/profanity/plugins
|
mkdir -p /etc/skel/.local/share/profanity/plugins
|
||||||
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /etc/skel/.local/share/profanity/plugins
|
cp "$INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py" /etc/skel/.local/share/profanity/plugins
|
||||||
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /home/$MY_USERNAME/.local/share/profanity/plugins
|
cp "$INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py" /home/$MY_USERNAME/.local/share/profanity/plugins
|
||||||
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
|
chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.local"
|
||||||
|
|
||||||
XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
|
XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
|
||||||
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
||||||
if [ ! -d $XMPP_CLIENT_DIR ]; then
|
if [ ! -d "$XMPP_CLIENT_DIR" ]; then
|
||||||
mkdir -p $XMPP_CLIENT_DIR
|
mkdir -p "$XMPP_CLIENT_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
||||||
MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_USERNAME@$DEFAULT_DOMAIN_NAME")
|
#MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_USERNAME@$DEFAULT_DOMAIN_NAME")
|
||||||
|
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ $ONION_ONLY == 'no' ]]; then
|
||||||
echo "[${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}]" > $XMPP_CLIENT_ACCOUNTS
|
{ echo "[${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}]";
|
||||||
echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'enabled=true';
|
||||||
echo "jid=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
|
echo "jid=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}";
|
||||||
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
|
echo "server=$XMPP_ONION_HOSTNAME";
|
||||||
# There is a bug where profanity doesn't refresh the screen
|
# There is a bug where profanity doesn't refresh the screen
|
||||||
# after gpg-agent has asked for a password, so for now
|
# after gpg-agent has asked for a password, so for now
|
||||||
# don't set the gpg key by default
|
# don't set the gpg key by default
|
||||||
#echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
|
#echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID";
|
||||||
echo "pgp.keyid=" >> $XMPP_CLIENT_ACCOUNTS
|
echo "pgp.keyid=";
|
||||||
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'resource=profanity';
|
||||||
echo "muc.service=chat.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
|
echo "muc.service=chat.${DEFAULT_DOMAIN_NAME}";
|
||||||
echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
echo "muc.nick=${MY_USERNAME}";
|
||||||
echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'presence.last=online';
|
||||||
echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'presence.login=online';
|
||||||
echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.online=0';
|
||||||
echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.chat=0';
|
||||||
echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.away=0';
|
||||||
echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.xa=0';
|
||||||
echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.dnd=0'; } > "$XMPP_CLIENT_ACCOUNTS"
|
||||||
if [ ${#XMPP_PASSWORD} -gt 2 ]; then
|
if [ ${#XMPP_PASSWORD} -gt 2 ]; then
|
||||||
echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
|
echo "password=$XMPP_PASSWORD" >> "$XMPP_CLIENT_ACCOUNTS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
|
if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
|
||||||
echo "[${MY_USERNAME}@${XMPP_ONION_HOSTNAME}]" >> $XMPP_CLIENT_ACCOUNTS
|
echo "[${MY_USERNAME}@${XMPP_ONION_HOSTNAME}]" >> "$XMPP_CLIENT_ACCOUNTS"
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ $ONION_ONLY == 'no' ]]; then
|
||||||
echo 'enabled=false' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'enabled=false' >> "$XMPP_CLIENT_ACCOUNTS"
|
||||||
else
|
else
|
||||||
echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'enabled=true' >> "$XMPP_CLIENT_ACCOUNTS"
|
||||||
fi
|
fi
|
||||||
echo "jid=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
{ echo "jid=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}";
|
||||||
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
|
echo "server=$XMPP_ONION_HOSTNAME";
|
||||||
# There is a bug where profanity doesn't refresh the screen
|
# There is a bug where profanity doesn't refresh the screen
|
||||||
# after gpg-agent has asked for a password, so for now
|
# after gpg-agent has asked for a password, so for now
|
||||||
# don't set the gpg key by default
|
# don't set the gpg key by default
|
||||||
#echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
|
#echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID";
|
||||||
echo "pgp.keyid=" >> $XMPP_CLIENT_ACCOUNTS
|
echo "pgp.keyid=";
|
||||||
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'resource=profanity';
|
||||||
echo "muc.service=${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
echo "muc.service=${XMPP_ONION_HOSTNAME}";
|
||||||
echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
echo "muc.nick=${MY_USERNAME}";
|
||||||
echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'presence.last=online';
|
||||||
echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'presence.login=online';
|
||||||
echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.online=0';
|
||||||
echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.chat=0';
|
||||||
echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.away=0';
|
||||||
echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.xa=0';
|
||||||
echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
|
echo 'priority.dnd=0'; } >> "$XMPP_CLIENT_ACCOUNTS"
|
||||||
if [ ${#XMPP_PASSWORD} -gt 2 ]; then
|
if [ ${#XMPP_PASSWORD} -gt 2 ]; then
|
||||||
echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
|
echo "password=$XMPP_PASSWORD" >> "$XMPP_CLIENT_ACCOUNTS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then
|
if [ ! -d "/home/$MY_USERNAME/.config/profanity" ]; then
|
||||||
mkdir -p /home/$MY_USERNAME/.config/profanity
|
mkdir -p "/home/$MY_USERNAME/.config/profanity"
|
||||||
fi
|
fi
|
||||||
echo '[connection]' > /home/$MY_USERNAME/.config/profanity/profrc
|
echo '[connection]' > "/home/$MY_USERNAME/.config/profanity/profrc"
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ $ONION_ONLY == 'no' ]]; then
|
||||||
echo "account=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo "account=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> "/home/$MY_USERNAME/.config/profanity/profrc"
|
||||||
else
|
else
|
||||||
echo "account=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo "account=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> "/home/$MY_USERNAME/.config/profanity/profrc"
|
||||||
fi
|
fi
|
||||||
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
{ echo '';
|
||||||
echo '[plugins]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo '[plugins]';
|
||||||
echo 'load=prof_omemo_plugin.py;' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo 'load=prof_omemo_plugin.py;';
|
||||||
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo '';
|
||||||
echo '[otr]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo '[otr]';
|
||||||
echo 'policy=opportunistic' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo 'policy=opportunistic';
|
||||||
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo 'log=off';
|
||||||
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo '';
|
||||||
echo '[pgp]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo '[pgp]';
|
||||||
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo 'log=off';
|
||||||
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo '';
|
||||||
echo '[ui]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo '[ui]';
|
||||||
echo 'enc.warn=true' >> /home/$MY_USERNAME/.config/profanity/profrc
|
echo 'enc.warn=true'; } >> "/home/$MY_USERNAME/.config/profanity/profrc"
|
||||||
|
|
||||||
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
|
chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.local"
|
||||||
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
|
chown -R "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.config"
|
||||||
|
|
||||||
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
|
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
|
||||||
APP_INSTALLED=1
|
APP_INSTALLED=1
|
||||||
|
|
|
@ -61,15 +61,15 @@ function logging_off_radicale {
|
||||||
function remove_user_radicale {
|
function remove_user_radicale {
|
||||||
remove_username="$1"
|
remove_username="$1"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $remove_username --rmapp radicale
|
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp radicale
|
||||||
|
|
||||||
if grep -q "${remove_username}:" ${RADICALE_USERS}; then
|
if grep -q "${remove_username}:" ${RADICALE_USERS}; then
|
||||||
sed -i "/${remove_username}:/d" ${RADICALE_USERS}
|
sed -i "/${remove_username}:/d" ${RADICALE_USERS}
|
||||||
if [ -d /var/www/radicale/collections/${remove_username} ]; then
|
if [ -d "/var/www/radicale/collections/${remove_username}" ]; then
|
||||||
rm -rf /var/www/radicale/collections/${remove_username}
|
rm -rf "/var/www/radicale/collections/${remove_username}"
|
||||||
fi
|
fi
|
||||||
if [ -f /var/www/radicale/collections/${remove_username}.props ]; then
|
if [ -f "/var/www/radicale/collections/${remove_username}.props" ]; then
|
||||||
rm /var/www/radicale/collections/${remove_username}.props
|
rm "/var/www/radicale/collections/${remove_username}.props"
|
||||||
fi
|
fi
|
||||||
systemctl restart radicale
|
systemctl restart radicale
|
||||||
fi
|
fi
|
||||||
|
@ -79,7 +79,7 @@ function add_user_radicale {
|
||||||
new_username="$1"
|
new_username="$1"
|
||||||
new_user_password="$2"
|
new_user_password="$2"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $new_username -a radicale -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$new_username" -a radicale -p "$new_user_password"
|
||||||
|
|
||||||
if [ ! -f ${RADICALE_USERS} ]; then
|
if [ ! -f ${RADICALE_USERS} ]; then
|
||||||
touch ${RADICALE_USERS}
|
touch ${RADICALE_USERS}
|
||||||
|
@ -88,13 +88,13 @@ function add_user_radicale {
|
||||||
if ! grep -q "$new_username:" ${RADICALE_USERS}; then
|
if ! grep -q "$new_username:" ${RADICALE_USERS}; then
|
||||||
htpasswd -bd ${RADICALE_USERS} "$new_username" "$new_user_password"
|
htpasswd -bd ${RADICALE_USERS} "$new_username" "$new_user_password"
|
||||||
|
|
||||||
echo '{"ICAL:calendar-color": "#9e50df"}' > /var/www/radicale/collections/${new_username}.props
|
echo '{"ICAL:calendar-color": "#9e50df"}' > "/var/www/radicale/collections/${new_username}.props"
|
||||||
mkdir /var/www/radicale/collections/${new_username}
|
mkdir "/var/www/radicale/collections/${new_username}"
|
||||||
echo '{"ICAL:calendar-color": "#de631a", "tag": "VCALENDAR"}' > /var/www/radicale/collections/${new_username}/calendar.props
|
echo '{"ICAL:calendar-color": "#de631a", "tag": "VCALENDAR"}' > "/var/www/radicale/collections/${new_username}/calendar.props"
|
||||||
echo 'BEGIN:VCALENDAR' > /var/www/radicale/collections/${new_username}/calendar
|
{ echo 'BEGIN:VCALENDAR';
|
||||||
echo 'PRODID:-//Radicale//NONSGML Radicale Server//EN' >> /var/www/radicale/collections/${new_username}/calendar
|
echo 'PRODID:-//Radicale//NONSGML Radicale Server//EN';
|
||||||
echo 'VERSION:2.0' >> /var/www/radicale/collections/${new_username}/calendar
|
echo 'VERSION:2.0';
|
||||||
echo 'END:VCALENDAR' >> /var/www/radicale/collections/${new_username}/calendar
|
echo 'END:VCALENDAR'; } >> "/var/www/radicale/collections/${new_username}/calendar"
|
||||||
|
|
||||||
chown -R www-data:www-data /var/www/radicale
|
chown -R www-data:www-data /var/www/radicale
|
||||||
chmod -R 755 /var/www/radicale/*
|
chmod -R 755 /var/www/radicale/*
|
||||||
|
@ -107,7 +107,7 @@ function change_password_radicale {
|
||||||
existing_username="$1"
|
existing_username="$1"
|
||||||
new_user_password="$2"
|
new_user_password="$2"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $existing_username -a radicale -p "$new_user_password"
|
"${PROJECT_NAME}-pass" -u "$existing_username" -a radicale -p "$new_user_password"
|
||||||
|
|
||||||
if grep -q "${existing_username}:" ${RADICALE_USERS}; then
|
if grep -q "${existing_username}:" ${RADICALE_USERS}; then
|
||||||
sed -i "/${existing_username}:/d" ${RADICALE_USERS}
|
sed -i "/${existing_username}:/d" ${RADICALE_USERS}
|
||||||
|
@ -127,14 +127,14 @@ function reconfigure_radicale {
|
||||||
rm -rf /var/log/radicale/*
|
rm -rf /var/log/radicale/*
|
||||||
|
|
||||||
# create an admin password
|
# create an admin password
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
RADICALE_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
RADICALE_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
RADICALE_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
RADICALE_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
add_user_radicale "$MY_USERNAME" "$RADICALE_PASSWORD"
|
add_user_radicale "$MY_USERNAME" "$RADICALE_PASSWORD"
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a radicale -p "$RADICALE_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a radicale -p "$RADICALE_PASSWORD"
|
||||||
|
|
||||||
touch /var/log/radicale/radicale.log
|
touch /var/log/radicale/radicale.log
|
||||||
chown -R www-data:www-data /var/log/radicale
|
chown -R www-data:www-data /var/log/radicale
|
||||||
|
@ -145,7 +145,7 @@ function upgrade_radicale {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep -q "radicale version:" $COMPLETION_FILE; then
|
if ! grep -q "radicale version:" "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ function upgrade_radicale {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get the source
|
# get the source
|
||||||
cd /var/www/radicale
|
cd /var/www/radicale || exit 62784628468
|
||||||
wget ${RADICALE_DOWNLOAD_URL}${RADICALE_VERSION}.tar.gz
|
wget ${RADICALE_DOWNLOAD_URL}${RADICALE_VERSION}.tar.gz
|
||||||
|
|
||||||
# check the hash
|
# check the hash
|
||||||
|
@ -170,7 +170,7 @@ function upgrade_radicale {
|
||||||
exit 73529
|
exit 73529
|
||||||
fi
|
fi
|
||||||
rm Radicale-${RADICALE_VERSION}.tar.gz
|
rm Radicale-${RADICALE_VERSION}.tar.gz
|
||||||
cd Radicale-${RADICALE_VERSION}
|
cd "Radicale-${RADICALE_VERSION}" || exit 264824684
|
||||||
|
|
||||||
# move the old command
|
# move the old command
|
||||||
mv /usr/local/bin/radicale /usr/local/bin/radicale_previous
|
mv /usr/local/bin/radicale /usr/local/bin/radicale_previous
|
||||||
|
@ -186,9 +186,9 @@ function upgrade_radicale {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove the old source
|
# remove the old source
|
||||||
rm -rf Radicale-${CURR_RADICALE_VERSION}
|
rm -rf "Radicale-${CURR_RADICALE_VERSION}" || exit 6842684282
|
||||||
|
|
||||||
sed -i "s|radicale version.*|radicale version:$RADICALE_VERSION|g" ${COMPLETION_FILE}
|
sed -i "s|radicale version.*|radicale version:$RADICALE_VERSION|g" "${COMPLETION_FILE}"
|
||||||
chown -R www-data:www-data /var/www/radicale
|
chown -R www-data:www-data /var/www/radicale
|
||||||
systemctl restart radicale
|
systemctl restart radicale
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
@ -219,6 +219,7 @@ function restore_local_radicale {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
|
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
function_check backup_unmount_drive
|
function_check backup_unmount_drive
|
||||||
backup_unmount_drive
|
backup_unmount_drive
|
||||||
|
@ -233,6 +234,7 @@ function restore_local_radicale {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/radicale/*
|
cp -r $temp_restore_dir/* /var/www/radicale/*
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
function_check backup_unmount_drive
|
function_check backup_unmount_drive
|
||||||
backup_unmount_drive
|
backup_unmount_drive
|
||||||
|
@ -264,6 +266,7 @@ function restore_remote_radicale {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
|
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 236746
|
exit 236746
|
||||||
fi
|
fi
|
||||||
|
@ -276,6 +279,7 @@ function restore_remote_radicale {
|
||||||
else
|
else
|
||||||
cp -r $temp_restore_dir/* /var/www/radicale
|
cp -r $temp_restore_dir/* /var/www/radicale
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 3674284
|
exit 3674284
|
||||||
fi
|
fi
|
||||||
|
@ -332,17 +336,17 @@ function remove_radicale {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
remove_completion_param install_radicale
|
remove_completion_param install_radicale
|
||||||
sed -i '/radicale/d' $COMPLETION_FILE
|
sed -i '/radicale/d' "$COMPLETION_FILE"
|
||||||
sed -i '/# Start radicale/,/# End radicale/d' /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
sed -i '/# Start radicale/,/# End radicale/d' "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_radicale {
|
function install_radicale {
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ $ONION_ONLY == 'no' ]]; then
|
||||||
# obtain a cert for the default domain
|
# obtain a cert for the default domain
|
||||||
if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then
|
if [[ "$(cert_exists "${DEFAULT_DOMAIN_NAME}" pem)" == "0" ]]; then
|
||||||
echo $'Obtaining certificate for the main domain'
|
echo $'Obtaining certificate for the main domain'
|
||||||
create_site_certificate ${DEFAULT_DOMAIN_NAME} 'yes'
|
create_site_certificate "${DEFAULT_DOMAIN_NAME}" 'yes'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -368,7 +372,7 @@ function install_radicale {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get the source
|
# get the source
|
||||||
cd /var/www/radicale
|
cd /var/www/radicale || exit 462874628
|
||||||
wget ${RADICALE_DOWNLOAD_URL}${RADICALE_VERSION}.tar.gz
|
wget ${RADICALE_DOWNLOAD_URL}${RADICALE_VERSION}.tar.gz
|
||||||
|
|
||||||
# check the hash
|
# check the hash
|
||||||
|
@ -383,7 +387,7 @@ function install_radicale {
|
||||||
exit 623252
|
exit 623252
|
||||||
fi
|
fi
|
||||||
rm Radicale-${RADICALE_VERSION}.tar.gz
|
rm Radicale-${RADICALE_VERSION}.tar.gz
|
||||||
cd Radicale-${RADICALE_VERSION}
|
cd "Radicale-${RADICALE_VERSION}" || exit 872462842
|
||||||
python setup.py install
|
python setup.py install
|
||||||
if [ ! -f /usr/local/bin/radicale ]; then
|
if [ ! -f /usr/local/bin/radicale ]; then
|
||||||
echo $'Radicale did not install'
|
echo $'Radicale did not install'
|
||||||
|
@ -398,52 +402,52 @@ function install_radicale {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create the configuration
|
# create the configuration
|
||||||
echo '[server]' > ${RADICALE_DIRECTORY}/config
|
{ echo '[server]';
|
||||||
echo 'hosts=localhost:52322' >> ${RADICALE_DIRECTORY}/config
|
echo 'hosts=localhost:52322';
|
||||||
echo 'ssl = False' >> ${RADICALE_DIRECTORY}/config
|
echo 'ssl = False';
|
||||||
echo 'daemon = False' >> ${RADICALE_DIRECTORY}/config
|
echo 'daemon = False';
|
||||||
echo 'base_prefix=/radicale/' >> ${RADICALE_DIRECTORY}/config
|
echo 'base_prefix=/radicale/';
|
||||||
echo '' >> ${RADICALE_DIRECTORY}/config
|
echo '';
|
||||||
echo '[storage]' >> ${RADICALE_DIRECTORY}/config
|
echo '[storage]';
|
||||||
echo 'type = filesystem' >> ${RADICALE_DIRECTORY}/config
|
echo 'type = filesystem';
|
||||||
echo "filesystem_folder = /var/www/radicale/collections" >> ${RADICALE_DIRECTORY}/config
|
echo "filesystem_folder = /var/www/radicale/collections";
|
||||||
echo '' >> ${RADICALE_DIRECTORY}/config
|
echo '';
|
||||||
echo '[well-known]' >> ${RADICALE_DIRECTORY}/config
|
echo '[well-known]';
|
||||||
echo "caldav = '/%(user)s/caldav/'" >> ${RADICALE_DIRECTORY}/config
|
echo "caldav = '/%(user)s/caldav/'";
|
||||||
echo "carddav = '/%(user)s/carddav/'" >> ${RADICALE_DIRECTORY}/config
|
echo "carddav = '/%(user)s/carddav/'";
|
||||||
echo '' >> ${RADICALE_DIRECTORY}/config
|
echo '';
|
||||||
echo '#[auth]' >> ${RADICALE_DIRECTORY}/config
|
echo '#[auth]';
|
||||||
echo '#imap_hostname = localhost' >> ${RADICALE_DIRECTORY}/config
|
echo '#imap_hostname = localhost';
|
||||||
echo '#imap_port = 143' >> ${RADICALE_DIRECTORY}/config
|
echo '#imap_port = 143';
|
||||||
echo '#imap_ssl = False' >> ${RADICALE_DIRECTORY}/config
|
echo '#imap_ssl = False';
|
||||||
echo '' >> ${RADICALE_DIRECTORY}/config
|
echo '';
|
||||||
echo '[logging]' >> ${RADICALE_DIRECTORY}/config
|
echo '[logging]';
|
||||||
echo 'debug = False' >> ${RADICALE_DIRECTORY}/config
|
echo 'debug = False'; } > "${RADICALE_DIRECTORY}/config"
|
||||||
|
|
||||||
# create an admin password
|
# create an admin password
|
||||||
if [ ${#RADICALE_PASSWORD} -lt 8 ]; then
|
if [ ${#RADICALE_PASSWORD} -lt 8 ]; then
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
RADICALE_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
RADICALE_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
RADICALE_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
RADICALE_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
add_user_radicale "$MY_USERNAME" "$RADICALE_PASSWORD"
|
add_user_radicale "$MY_USERNAME" "$RADICALE_PASSWORD"
|
||||||
|
|
||||||
echo '[Unit]' > /etc/systemd/system/radicale.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=Radicale CalDAV Server' >> /etc/systemd/system/radicale.service
|
echo 'Description=Radicale CalDAV Server';
|
||||||
echo 'After=network.target' >> /etc/systemd/system/radicale.service
|
echo 'After=network.target';
|
||||||
echo '' >> /etc/systemd/system/radicale.service
|
echo '';
|
||||||
echo '[Service]' >> /etc/systemd/system/radicale.service
|
echo '[Service]';
|
||||||
echo 'Type=simple' >> /etc/systemd/system/radicale.service
|
echo 'Type=simple';
|
||||||
echo 'User=www-data' >> /etc/systemd/system/radicale.service
|
echo 'User=www-data';
|
||||||
echo 'Group=www-data' >> /etc/systemd/system/radicale.service
|
echo 'Group=www-data';
|
||||||
echo "ExecStart=/usr/local/bin/radicale --config ${RADICALE_DIRECTORY}/config" >> /etc/systemd/system/radicale.service
|
echo "ExecStart=/usr/local/bin/radicale --config ${RADICALE_DIRECTORY}/config";
|
||||||
echo 'Restart=on-failure' >> /etc/systemd/system/radicale.service
|
echo 'Restart=on-failure';
|
||||||
echo 'RestartSec=10' >> /etc/systemd/system/radicale.service
|
echo 'RestartSec=10';
|
||||||
echo '' >> /etc/systemd/system/radicale.service
|
echo '';
|
||||||
echo '[Install]' >> /etc/systemd/system/radicale.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/radicale.service
|
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/radicale.service
|
||||||
|
|
||||||
addresses_str=$"Addresses"
|
addresses_str=$"Addresses"
|
||||||
echo "{\"tag\": \"VADDRESSBOOK\", \"D:displayname\": \"${addresses_str}\"}" > /var/www/radicale/collections/addresses.props
|
echo "{\"tag\": \"VADDRESSBOOK\", \"D:displayname\": \"${addresses_str}\"}" > /var/www/radicale/collections/addresses.props
|
||||||
|
@ -461,107 +465,107 @@ function install_radicale {
|
||||||
systemctl enable radicale
|
systemctl enable radicale
|
||||||
systemctl start radicale
|
systemctl start radicale
|
||||||
|
|
||||||
if [ ! -f /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} ]; then
|
if [ ! -f "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}" ]; then
|
||||||
# create a new site config
|
# create a new site config
|
||||||
RADICALE_ONION_HOSTNAME=$(add_onion_service radicale 80 ${RADICALE_ONION_PORT})
|
RADICALE_ONION_HOSTNAME=$(add_onion_service radicale 80 ${RADICALE_ONION_PORT})
|
||||||
|
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ $ONION_ONLY == 'no' ]]; then
|
||||||
echo 'server {' > /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
{ echo 'server {';
|
||||||
echo " listen 443 ssl;" >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " listen 443 ssl;";
|
||||||
echo " #listen [::]:443 ssl;" >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " #listen [::]:443 ssl;";
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ''; } > "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl ${DEFAULT_DOMAIN_NAME} mobile
|
nginx_ssl "${DEFAULT_DOMAIN_NAME}" mobile
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing ${DEFAULT_DOMAIN_NAME}
|
nginx_disable_sniffing "${DEFAULT_DOMAIN_NAME}"
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
{ echo '';
|
||||||
echo " server_name ${DEFAULT_DOMAIN_NAME};" >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " server_name ${DEFAULT_DOMAIN_NAME};";
|
||||||
|
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' # Start radicale' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' # Start radicale';
|
||||||
echo ' location @radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location @radicale {';
|
||||||
echo ' auth_basic "Radicale";' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' auth_basic "Radicale";';
|
||||||
echo ' auth_basic_user_file /var/www/radicale/users;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' auth_basic_user_file /var/www/radicale/users;';
|
||||||
echo ' proxy_pass http://localhost:52322;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' proxy_pass http://localhost:52322;';
|
||||||
echo ' proxy_buffering off;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' proxy_buffering off;';
|
||||||
echo ' proxy_set_header Host $host;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_set_header X-Forwarded-Proto $scheme;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header X-Forwarded-Proto \$scheme;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' location /radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location /radicale {';
|
||||||
echo ' try_files $uri @radicale;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " try_files \$uri @radicale;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' location /.well-known/carddav {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location /.well-known/carddav {';
|
||||||
echo ' try_files $uri @radicale;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " try_files \$uri @radicale;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' location /.well-known/caldav {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location /.well-known/caldav {';
|
||||||
echo ' try_files $uri @radicale;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " try_files \$uri @radicale;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo ' # End radicale' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' # End radicale';
|
||||||
echo '}' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '}';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ''; } >> "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"
|
||||||
else
|
else
|
||||||
echo -n '' > /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo -n '' > "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
{ echo 'server {';
|
||||||
echo " listen localhost:${RADICALE_ONION_PORT} default_server;" >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " listen localhost:${RADICALE_ONION_PORT} default_server;";
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo " server_name ${RADICALE_ONION_HOSTNAME};" >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " server_name ${RADICALE_ONION_HOSTNAME};";
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' # Start radicale' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' # Start radicale';
|
||||||
echo ' location @radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location @radicale {';
|
||||||
echo ' auth_basic "Radicale";' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' auth_basic "Radicale";';
|
||||||
echo ' auth_basic_user_file /var/www/radicale/users;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' auth_basic_user_file /var/www/radicale/users;';
|
||||||
echo ' proxy_pass http://localhost:52322;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' proxy_pass http://localhost:52322;';
|
||||||
echo ' proxy_buffering off;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' proxy_buffering off;';
|
||||||
echo ' proxy_set_header Host $host;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_set_header X-Forwarded-Proto $scheme;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " proxy_set_header X-Forwarded-Proto \$scheme;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' location /radicale {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location /radicale {';
|
||||||
echo ' try_files $uri @radicale;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " try_files \$uri @radicale;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' location /.well-known/carddav {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location /.well-known/carddav {';
|
||||||
echo ' try_files $uri @radicale;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " try_files \$uri @radicale;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '';
|
||||||
echo ' location /.well-known/caldav {' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' location /.well-known/caldav {';
|
||||||
echo ' try_files $uri @radicale;' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo " try_files \$uri @radicale;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' }';
|
||||||
echo ' # End radicale' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo ' # End radicale';
|
||||||
echo '}' >> /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
echo '}'; } >> "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"
|
||||||
|
|
||||||
set_completion_param "radicale onion domain" "${RADICALE_ONION_HOSTNAME}"
|
set_completion_param "radicale onion domain" "${RADICALE_ONION_HOSTNAME}"
|
||||||
else
|
else
|
||||||
# alter the existing site config
|
# alter the existing site config
|
||||||
if ! grep -q "# Start radicale" /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}; then
|
if ! grep -q "# Start radicale" "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"; then
|
||||||
sed -i '/]:443/a # Start radicale\n location @radicale {\n auth_basic "Radicale";\n auth_basic_user_file \/var\/www\/radicale\/users;\n proxy_pass http:\/\/localhost:52322;\n proxy_buffering off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n }\n\n location \/radicale {\n try_files $uri @radicale;\n }\n\n location \/.well-known\/carddav {\n try_files $uri @radicale;\n }\n\n location \/.well-known\/caldav {\n try_files $uri @radicale;\n }\n # End radicale' /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
sed -i "/]:443/a # Start radicale\\n location @radicale {\\n auth_basic \"Radicale\";\\n auth_basic_user_file \\/var\\/www\\/radicale\\/users;\\n proxy_pass http:\\/\\/localhost:52322;\\n proxy_buffering off;\\n proxy_set_header Host $host;\\n proxy_set_header X-Real-IP $remote_addr;\\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\\n proxy_set_header X-Forwarded-Proto $scheme;\\n }\\n\\n location \\/radicale {\\n try_files $uri @radicale;\\n }\n\n location \\/.well-known\\/carddav {\\n try_files $uri @radicale;\\n }\\n\\n location \\/.well-known\\/caldav {\\n try_files $uri @radicale;\\n }\n # End radicale" "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"
|
||||||
sed -i '/listen localhost/a # Start radicale\n location @radicale {\n auth_basic "Radicale";\n auth_basic_user_file \/var\/www\/radicale\/users;\n proxy_pass http:\/\/localhost:52322;\n proxy_buffering off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n }\n\n location \/radicale {\n try_files $uri @radicale;\n }\n\n location \/.well-known\/carddav {\n try_files $uri @radicale;\n }\n\n location \/.well-known\/caldav {\n try_files $uri @radicale;\n }\n # End radicale' /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}
|
sed -i "/listen localhost/a # Start radicale\\n location @radicale {\\n auth_basic \"Radicale\";\\n auth_basic_user_file \\/var\\/www\\/radicale\\/users;\\n proxy_pass http:\\/\\/localhost:52322;\\n proxy_buffering off;\\n proxy_set_header Host $host;\\n proxy_set_header X-Real-IP $remote_addr;\\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\\n proxy_set_header X-Forwarded-Proto $scheme;\\n }\\n\\n location \/radicale {\\n try_files $uri @radicale;\\n }\\n\\n location \\/.well-known\\/carddav {\\n try_files $uri @radicale;\\n }\\n\\n location \\/.well-known\\/caldav {\\n try_files $uri @radicale;\\n }\\n # End radicale" "/etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create a certificate
|
# create a certificate
|
||||||
if [ ! -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
|
if [ ! -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
||||||
if [ ! -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt ]; then
|
if [ ! -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt" ]; then
|
||||||
${PROJECT_NAME}-addcert -h $DEFAULT_DOMAIN_NAME --dhkey ${DH_KEYLENGTH}
|
"${PROJECT_NAME}-addcert" -h "$DEFAULT_DOMAIN_NAME" --dhkey "${DH_KEYLENGTH}"
|
||||||
check_certificates $DEFAULT_DOMAIN_NAME
|
check_certificates "$DEFAULT_DOMAIN_NAME"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
||||||
sed -i "s|radicale.crt|${DEFAULT_DOMAIN_NAME}.pem|g" /etc/nginx/sites-available/radicale
|
sed -i "s|radicale.crt|${DEFAULT_DOMAIN_NAME}.pem|g" /etc/nginx/sites-available/radicale
|
||||||
sed -i "s|radicale.pem|${DEFAULT_DOMAIN_NAME}.pem|g" /etc/nginx/sites-available/radicale
|
sed -i "s|radicale.pem|${DEFAULT_DOMAIN_NAME}.pem|g" /etc/nginx/sites-available/radicale
|
||||||
fi
|
fi
|
||||||
|
@ -572,13 +576,13 @@ function install_radicale {
|
||||||
|
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a radicale -p "$RADICALE_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a radicale -p "$RADICALE_PASSWORD"
|
||||||
|
|
||||||
# keep track of the version so we can check for upgrades
|
# keep track of the version so we can check for upgrades
|
||||||
if ! grep -q "radicale version:" ${COMPLETION_FILE}; then
|
if ! grep -q "radicale version:" "${COMPLETION_FILE}"; then
|
||||||
echo "radicale version:${RADICALE_VERSION}" >> ${COMPLETION_FILE}
|
echo "radicale version:${RADICALE_VERSION}" >> "${COMPLETION_FILE}"
|
||||||
else
|
else
|
||||||
sed -i "s|radicale version.*|radicale version:${RADICALE_VERSION}|g" ${COMPLETION_FILE}
|
sed -i "s|radicale version.*|radicale version:${RADICALE_VERSION}|g" "${COMPLETION_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APP_INSTALLED=1
|
APP_INSTALLED=1
|
||||||
|
|
|
@ -76,39 +76,40 @@ function install_interactive_riot {
|
||||||
RIOT_DETAILS_COMPLETE=
|
RIOT_DETAILS_COMPLETE=
|
||||||
while [ ! $RIOT_DETAILS_COMPLETE ]
|
while [ ! $RIOT_DETAILS_COMPLETE ]
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"Riot Web user interface for Matrix" \
|
--title $"Riot Web user interface for Matrix" \
|
||||||
--form $"\nPlease enter your details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 3 \
|
--form $"\\nPlease enter your details.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 3 \
|
||||||
$"Domain:" 1 1 "$(grep 'RIOT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
$"Domain:" 1 1 "$(grep 'RIOT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
||||||
$"Code:" 2 1 "$(grep 'RIOT_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 40 255 \
|
$"Code:" 2 1 "$(grep 'RIOT_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 15 40 255 \
|
||||||
2> $data
|
2> "$data"
|
||||||
else
|
else
|
||||||
dialog --backtitle $"Freedombone Configuration" \
|
dialog --backtitle $"Freedombone Configuration" \
|
||||||
--title $"Riot Web user interface for Matrix" \
|
--title $"Riot Web user interface for Matrix" \
|
||||||
--form $"\nPlease enter your details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 2 \
|
--form $"\\nPlease enter your details. The background image URL can be left blank.\\n\\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 13 65 2 \
|
||||||
$"Domain:" 1 1 "$(grep 'RIOT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
$"Domain:" 1 1 "$(grep 'RIOT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 15 40 40 \
|
||||||
2> $data
|
2> "$data"
|
||||||
fi
|
fi
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) exit 1;;
|
1) rm -f "$data"
|
||||||
255) exit 1;;
|
exit 1;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
RIOT_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
RIOT_DOMAIN_NAME=$(sed -n 1p < "$data")
|
||||||
if [ $RIOT_DOMAIN_NAME ]; then
|
if [ "$RIOT_DOMAIN_NAME" ]; then
|
||||||
TEST_DOMAIN_NAME=$RIOT_DOMAIN_NAME
|
TEST_DOMAIN_NAME=$RIOT_DOMAIN_NAME
|
||||||
validate_domain_name
|
validate_domain_name
|
||||||
if [[ $TEST_DOMAIN_NAME != $RIOT_DOMAIN_NAME ]]; then
|
if [[ "$TEST_DOMAIN_NAME" != "$RIOT_DOMAIN_NAME" ]]; then
|
||||||
RIOT_DOMAIN_NAME=
|
RIOT_DOMAIN_NAME=
|
||||||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||||||
else
|
else
|
||||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||||
RIOT_CODE=$(cat $data | sed -n 2p)
|
RIOT_CODE=$(sed -n 2p < "$data")
|
||||||
validate_freedns_code "$RIOT_CODE"
|
validate_freedns_code "$RIOT_CODE"
|
||||||
if [ ! $VALID_CODE ]; then
|
if [ ! "$VALID_CODE" ]; then
|
||||||
RIOT_DOMAIN_NAME=
|
RIOT_DOMAIN_NAME=
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -117,6 +118,7 @@ function install_interactive_riot {
|
||||||
if [ $RIOT_DOMAIN_NAME ]; then
|
if [ $RIOT_DOMAIN_NAME ]; then
|
||||||
RIOT_DETAILS_COMPLETE="yes"
|
RIOT_DETAILS_COMPLETE="yes"
|
||||||
fi
|
fi
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
|
|
||||||
# save the results in the config file
|
# save the results in the config file
|
||||||
|
@ -132,14 +134,14 @@ function reconfigure_riot {
|
||||||
|
|
||||||
function riot_download {
|
function riot_download {
|
||||||
# download
|
# download
|
||||||
if [ ! -f $INSTALL_DIR/${RIOT_FILENAME}.tar.gz ]; then
|
if [ ! -f "$INSTALL_DIR/${RIOT_FILENAME}.tar.gz" ]; then
|
||||||
wget ${RIOT_DOWNLOAD_URL}/${RIOT_FILENAME}.tar.gz -O $INSTALL_DIR/${RIOT_FILENAME}.tar.gz
|
wget "${RIOT_DOWNLOAD_URL}/${RIOT_FILENAME}.tar.gz" -O "$INSTALL_DIR/${RIOT_FILENAME}.tar.gz"
|
||||||
fi
|
fi
|
||||||
if [ ! -f $INSTALL_DIR/${RIOT_FILENAME}.tar.gz ]; then
|
if [ ! -f "$INSTALL_DIR/${RIOT_FILENAME}.tar.gz" ]; then
|
||||||
echo $'Unable to download Riot Web from releases'
|
echo $'Unable to download Riot Web from releases'
|
||||||
exit 62836
|
exit 62836
|
||||||
fi
|
fi
|
||||||
cd $INSTALL_DIR
|
cd "$INSTALL_DIR" || exit 2468724628
|
||||||
|
|
||||||
# check the hash
|
# check the hash
|
||||||
curr_hash=$(sha256sum ${RIOT_FILENAME}.tar.gz | awk -F ' ' '{print $1}')
|
curr_hash=$(sha256sum ${RIOT_FILENAME}.tar.gz | awk -F ' ' '{print $1}')
|
||||||
|
@ -149,17 +151,17 @@ function riot_download {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tar -xzvf ${RIOT_FILENAME}.tar.gz
|
tar -xzvf ${RIOT_FILENAME}.tar.gz
|
||||||
if [ ! -d $INSTALL_DIR/${RIOT_FILENAME} ]; then
|
if [ ! -d "$INSTALL_DIR/${RIOT_FILENAME}" ]; then
|
||||||
echo $'Unable to extract Riot Web tarball'
|
echo $'Unable to extract Riot Web tarball'
|
||||||
exit 542826
|
exit 542826
|
||||||
fi
|
fi
|
||||||
cp -r $INSTALL_DIR/${RIOT_FILENAME}/* /var/www/$RIOT_DOMAIN_NAME/htdocs
|
cp -r "$INSTALL_DIR/${RIOT_FILENAME}/*" "/var/www/$RIOT_DOMAIN_NAME/htdocs"
|
||||||
|
|
||||||
chown -R www-data:www-data /var/www/$RIOT_DOMAIN_NAME/htdocs
|
chown -R www-data:www-data "/var/www/$RIOT_DOMAIN_NAME/htdocs"
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_riot {
|
function upgrade_riot {
|
||||||
if ! grep -q 'riot version:' $COMPLETION_FILE; then
|
if ! grep -q 'riot version:' "$COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -171,7 +173,7 @@ function upgrade_riot {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
riot_download
|
riot_download
|
||||||
sed -i "s|riot version.*|riot version:$RIOT_VERSION|g" ${COMPLETION_FILE}
|
sed -i "s|riot version.*|riot version:$RIOT_VERSION|g" "${COMPLETION_FILE}"
|
||||||
riot_remove_bad_links
|
riot_remove_bad_links
|
||||||
|
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
@ -207,7 +209,7 @@ function remove_riot {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
remove_completion_param install_riot
|
remove_completion_param install_riot
|
||||||
sed -i '/riot /d' $COMPLETION_FILE
|
sed -i '/riot /d' "$COMPLETION_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_riot {
|
function install_riot {
|
||||||
|
@ -216,7 +218,7 @@ function install_riot {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check that matrix has been installed
|
# check that matrix has been installed
|
||||||
if [ ! $MATRIX_DOMAIN_NAME ]; then
|
if [ ! "$MATRIX_DOMAIN_NAME" ]; then
|
||||||
exit 687292
|
exit 687292
|
||||||
fi
|
fi
|
||||||
if [[ "$MATRIX_DOMAIN_NAME" != *'.'* ]]; then
|
if [[ "$MATRIX_DOMAIN_NAME" != *'.'* ]]; then
|
||||||
|
@ -235,32 +237,32 @@ function install_riot {
|
||||||
mkdir -p /var/www/$RIOT_DOMAIN_NAME/htdocs
|
mkdir -p /var/www/$RIOT_DOMAIN_NAME/htdocs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $INSTALL_DIR ]; then
|
if [ ! -d "$INSTALL_DIR" ]; then
|
||||||
mkdir $INSTALL_DIR
|
mkdir "$INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
riot_download
|
riot_download
|
||||||
|
|
||||||
cd /var/www/$RIOT_DOMAIN_NAME/htdocs
|
cd "/var/www/$RIOT_DOMAIN_NAME/htdocs" || exit 4628462876
|
||||||
|
|
||||||
if [[ $ONION_ONLY == 'no' ]]; then
|
if [[ "$ONION_ONLY" == 'no' ]]; then
|
||||||
riot_config_file="config.${RIOT_DOMAIN_NAME}.json"
|
riot_config_file="config.${RIOT_DOMAIN_NAME}.json"
|
||||||
cp config.sample.json $riot_config_file
|
cp config.sample.json $riot_config_file
|
||||||
sed -i "s|\"default_hs_url\":.*|\"default_hs_url\": \"https://${MATRIX_DOMAIN_NAME}\",|g" $riot_config_file
|
sed -i "s|\"default_hs_url\":.*|\"default_hs_url\": \"https://${MATRIX_DOMAIN_NAME}\",|g" "$riot_config_file"
|
||||||
sed -i "s|\"default_is_url\":.*|\"default_is_url\": \"https://${MATRIX_DOMAIN_NAME}\",|g" $riot_config_file
|
sed -i "s|\"default_is_url\":.*|\"default_is_url\": \"https://${MATRIX_DOMAIN_NAME}\",|g" "$riot_config_file"
|
||||||
sed -i "s|\"bug_report_endpoint_url\":.*|\"bug_report_endpoint_url\": \"https://${MATRIX_DOMAIN_NAME}/bugs\",|g" $riot_config_file
|
sed -i "s|\"bug_report_endpoint_url\":.*|\"bug_report_endpoint_url\": \"https://${MATRIX_DOMAIN_NAME}/bugs\",|g" "$riot_config_file"
|
||||||
sed -i "/\"servers\":/a \"${MATRIX_DOMAIN_NAME}\"," $riot_config_file
|
sed -i "/\"servers\":/a \"${MATRIX_DOMAIN_NAME}\"," "$riot_config_file"
|
||||||
else
|
else
|
||||||
riot_config_file="config.${MATRIX_ONION_DOMAIN_NAME}.json"
|
riot_config_file="config.${MATRIX_ONION_DOMAIN_NAME}.json"
|
||||||
cp config.sample.json $riot_config_file
|
cp config.sample.json "$riot_config_file"
|
||||||
sed -i "s|\"default_hs_url\":.*|\"default_hs_url\": \"http://${MATRIX_ONION_DOMAIN_NAME}\",|g" $riot_config_file
|
sed -i "s|\"default_hs_url\":.*|\"default_hs_url\": \"http://${MATRIX_ONION_DOMAIN_NAME}\",|g" "$riot_config_file"
|
||||||
sed -i "s|\"default_is_url\":.*|\"default_is_url\": \"http://${MATRIX_ONION_DOMAIN_NAME}\",|g" $riot_config_file
|
sed -i "s|\"default_is_url\":.*|\"default_is_url\": \"http://${MATRIX_ONION_DOMAIN_NAME}\",|g" "$riot_config_file"
|
||||||
sed -i "s|\"bug_report_endpoint_url\":.*|\"bug_report_endpoint_url\": \"http://${MATRIX_ONION_DOMAIN_NAME}/bugs\",|g" $riot_config_file
|
sed -i "s|\"bug_report_endpoint_url\":.*|\"bug_report_endpoint_url\": \"http://${MATRIX_ONION_DOMAIN_NAME}/bugs\",|g" "$riot_config_file"
|
||||||
sed -i "/\"servers\":/a \"${MATRIX_ONION_DOMAIN_NAME}\"," $riot_config_file
|
sed -i "/\"servers\":/a \"${MATRIX_ONION_DOMAIN_NAME}\"," "$riot_config_file"
|
||||||
fi
|
fi
|
||||||
sed -i "s|\"integrations_ui_url\":.*|\"integrations_ui_url\": \"\",|g" $riot_config_file
|
sed -i "s|\"integrations_ui_url\":.*|\"integrations_ui_url\": \"\",|g" "$riot_config_file"
|
||||||
sed -i "s|\"integrations_rest_url\":.*|\"integrations_rest_url\": \"\",|g" $riot_config_file
|
sed -i "s|\"integrations_rest_url\":.*|\"integrations_rest_url\": \"\",|g" "$riot_config_file"
|
||||||
sed -i 's|https://piwik.riot.im/||g' $riot_config_file
|
sed -i 's|https://piwik.riot.im/||g' "$riot_config_file"
|
||||||
|
|
||||||
RIOT_ONION_HOSTNAME=$(add_onion_service riot 80 ${RIOT_ONION_PORT})
|
RIOT_ONION_HOSTNAME=$(add_onion_service riot 80 ${RIOT_ONION_PORT})
|
||||||
|
|
||||||
|
@ -268,68 +270,68 @@ function install_riot {
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $RIOT_DOMAIN_NAME
|
nginx_http_redirect $RIOT_DOMAIN_NAME
|
||||||
echo 'server {' >> $riot_nginx_site
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> $riot_nginx_site
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> $riot_nginx_site
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo " server_name $RIOT_DOMAIN_NAME;" >> $riot_nginx_site
|
echo " server_name $RIOT_DOMAIN_NAME;";
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' # Security' >> $riot_nginx_site
|
echo ' # Security'; } >> $riot_nginx_site
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $RIOT_DOMAIN_NAME
|
nginx_ssl $RIOT_DOMAIN_NAME
|
||||||
|
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $RIOT_DOMAIN_NAME
|
nginx_disable_sniffing $RIOT_DOMAIN_NAME
|
||||||
|
|
||||||
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $riot_nginx_site
|
{ echo ' add_header Strict-Transport-Security max-age=15768000;';
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' # Logs' >> $riot_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $riot_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $riot_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $riot_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$RIOT_DOMAIN_NAME/htdocs;" >> $riot_nginx_site
|
echo " root /var/www/$RIOT_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' index index.html;' >> $riot_nginx_site
|
echo ' index index.html;';
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' location / {' >> $riot_nginx_site
|
echo ' location / {'; } >> $riot_nginx_site
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $RIOT_DOMAIN_NAME '15m'
|
nginx_limits $RIOT_DOMAIN_NAME '15m'
|
||||||
echo ' }' >> $riot_nginx_site
|
{ echo ' }';
|
||||||
echo '}' >> $riot_nginx_site
|
echo '}';
|
||||||
echo '' >> $riot_nginx_site
|
echo ''; } >> $riot_nginx_site
|
||||||
else
|
else
|
||||||
echo -n '' > $riot_nginx_site
|
echo -n '' > $riot_nginx_site
|
||||||
fi
|
fi
|
||||||
echo 'server {' >> $riot_nginx_site
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:$RIOT_ONION_PORT default_server;" >> $riot_nginx_site
|
echo " listen 127.0.0.1:$RIOT_ONION_PORT default_server;";
|
||||||
echo " server_name $RIOT_ONION_HOSTNAME;" >> $riot_nginx_site
|
echo " server_name $RIOT_ONION_HOSTNAME;";
|
||||||
echo '' >> $riot_nginx_site
|
echo ''; } >> $riot_nginx_site
|
||||||
function_check nginx_disable_sniffing
|
function_check nginx_disable_sniffing
|
||||||
nginx_disable_sniffing $RIOT_DOMAIN_NAME
|
nginx_disable_sniffing $RIOT_DOMAIN_NAME
|
||||||
echo '' >> $riot_nginx_site
|
{ echo '';
|
||||||
echo ' # Logs' >> $riot_nginx_site
|
echo ' # Logs';
|
||||||
echo ' access_log /dev/null;' >> $riot_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $riot_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' # Root' >> $riot_nginx_site
|
echo ' # Root';
|
||||||
echo " root /var/www/$RIOT_DOMAIN_NAME/htdocs;" >> $riot_nginx_site
|
echo " root /var/www/$RIOT_DOMAIN_NAME/htdocs;";
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' index index.html;' >> $riot_nginx_site
|
echo ' index index.html;';
|
||||||
echo '' >> $riot_nginx_site
|
echo '';
|
||||||
echo ' location / {' >> $riot_nginx_site
|
echo ' location / {'; } >> $riot_nginx_site
|
||||||
function_check nginx_limits
|
function_check nginx_limits
|
||||||
nginx_limits $RIOT_DOMAIN_NAME '15m'
|
nginx_limits $RIOT_DOMAIN_NAME '15m'
|
||||||
echo ' }' >> $riot_nginx_site
|
echo ' }' >> "$riot_nginx_site"
|
||||||
echo '}' >> $riot_nginx_site
|
echo '}' >> "$riot_nginx_site"
|
||||||
|
|
||||||
sed '/Content-Security-Policy/d' $riot_nginx_site
|
sed '/Content-Security-Policy/d' "$riot_nginx_site"
|
||||||
sed -i 's| DENY;| SAMEORIGIN;|g' $riot_nginx_site
|
sed -i 's| DENY;| SAMEORIGIN;|g' "$riot_nginx_site"
|
||||||
sed -i 's|limit_conn conn_limit_per_ip.*|limit_conn conn_limit_per_ip 50;|g' $riot_nginx_site
|
sed -i 's|limit_conn conn_limit_per_ip.*|limit_conn conn_limit_per_ip 50;|g' "$riot_nginx_site"
|
||||||
sed -i 's|limit_req zone.*|limit_req zone=req_limit_per_ip burst=20 nodelay;|g' $riot_nginx_site
|
sed -i 's|limit_req zone.*|limit_req zone=req_limit_per_ip burst=20 nodelay;|g' "$riot_nginx_site"
|
||||||
|
|
||||||
function_check create_site_certificate
|
function_check create_site_certificate
|
||||||
if [ ! -f /etc/ssl/certs/${RIOT_DOMAIN_NAME}.pem ]; then
|
if [ ! -f "/etc/ssl/certs/${RIOT_DOMAIN_NAME}.pem" ]; then
|
||||||
create_site_certificate $RIOT_DOMAIN_NAME 'yes'
|
create_site_certificate "$RIOT_DOMAIN_NAME" 'yes'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check nginx_ensite
|
function_check nginx_ensite
|
||||||
|
@ -344,10 +346,10 @@ function install_riot {
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
set_completion_param "riot domain" "$RIOT_DOMAIN_NAME"
|
set_completion_param "riot domain" "$RIOT_DOMAIN_NAME"
|
||||||
if ! grep -q "riot version:" ${COMPLETION_FILE}; then
|
if ! grep -q "riot version:" "${COMPLETION_FILE}"; then
|
||||||
echo "riot version:${RIOT_VERSION}" >> ${COMPLETION_FILE}
|
echo "riot version:${RIOT_VERSION}" >> "${COMPLETION_FILE}"
|
||||||
else
|
else
|
||||||
sed -i "s|riot version.*|riot version:${RIOT_VERSION}|g" ${COMPLETION_FILE}
|
sed -i "s|riot version.*|riot version:${RIOT_VERSION}|g" "${COMPLETION_FILE}"
|
||||||
fi
|
fi
|
||||||
APP_INSTALLED=1
|
APP_INSTALLED=1
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,12 +62,13 @@ function logging_off_rss {
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_user_rss {
|
function remove_user_rss {
|
||||||
remove_username="$1"
|
echo -n ''
|
||||||
|
# remove_username="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_user_rss {
|
function add_user_rss {
|
||||||
new_username="$1"
|
# new_username="$1"
|
||||||
new_user_password="$2"
|
# new_user_password="$2"
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,26 +78,27 @@ function install_interactive_rss {
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_password_rss {
|
function change_password_rss {
|
||||||
curr_username="$1"
|
echo -n ''
|
||||||
new_user_password="$2"
|
# curr_username="$1"
|
||||||
|
# new_user_password="$2"
|
||||||
|
|
||||||
#${PROJECT_NAME}-pass -u "$curr_username" -a rss -p "$new_user_password"
|
#${PROJECT_NAME}-pass -u "$curr_username" -a rss -p "$new_user_password"
|
||||||
}
|
}
|
||||||
|
|
||||||
function rss_create_database {
|
function rss_create_database {
|
||||||
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
RSS_READER_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
RSS_READER_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
else
|
else
|
||||||
if [ ! $RSS_READER_ADMIN_PASSWORD ]; then
|
if [ ! "$RSS_READER_ADMIN_PASSWORD" ]; then
|
||||||
RSS_READER_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
RSS_READER_ADMIN_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! $RSS_READER_ADMIN_PASSWORD ]; then
|
if [ ! "$RSS_READER_ADMIN_PASSWORD" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function_check create_database
|
function_check create_database
|
||||||
create_database ttrss "$RSS_READER_ADMIN_PASSWORD" $MY_USERNAME
|
create_database ttrss "$RSS_READER_ADMIN_PASSWORD" "$MY_USERNAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
function reconfigure_rss {
|
function reconfigure_rss {
|
||||||
|
@ -131,8 +133,8 @@ function upgrade_rss {
|
||||||
# remove any previous install
|
# remove any previous install
|
||||||
if [ -d $RSS_READER_PATH/g2ttree-mobile ]; then
|
if [ -d $RSS_READER_PATH/g2ttree-mobile ]; then
|
||||||
if [[ $(is_completed "install_rss_mobile_reader") == "1" ]]; then
|
if [[ $(is_completed "install_rss_mobile_reader") == "1" ]]; then
|
||||||
sed -i '/install_rss_mobile_reader/d' $COMPLETION_FILE
|
sed -i '/install_rss_mobile_reader/d' "$COMPLETION_FILE"
|
||||||
sed -i '/rss mobile reader commit/d' $COMPLETION_FILE
|
sed -i '/rss mobile reader commit/d' "$COMPLETION_FILE"
|
||||||
rm -rf $RSS_READER_PATH/g2ttree-mobile
|
rm -rf $RSS_READER_PATH/g2ttree-mobile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -184,6 +186,7 @@ function restore_local_rss {
|
||||||
fi
|
fi
|
||||||
cp -r $temp_restore_dir/* /etc/share/tt-rss/
|
cp -r $temp_restore_dir/* /etc/share/tt-rss/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
function_check set_user_permissions
|
function_check set_user_permissions
|
||||||
set_user_permissions
|
set_user_permissions
|
||||||
|
@ -207,14 +210,14 @@ function restore_local_rss {
|
||||||
function_check rss_modifications
|
function_check rss_modifications
|
||||||
rss_modifications
|
rss_modifications
|
||||||
|
|
||||||
if [ -d $USB_MOUNT/backup/ttrss ]; then
|
if [ -d "$USB_MOUNT/backup/ttrss" ]; then
|
||||||
chown -R www-data:www-data /etc/share/tt-rss
|
chown -R www-data:www-data /etc/share/tt-rss
|
||||||
if [ -d $temp_restore_dir ]; then
|
if [ -d $temp_restore_dir ]; then
|
||||||
rm -rf $temp_restore_dir
|
rm -rf $temp_restore_dir
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
MARIADB_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
|
||||||
sed -i "s|define('DB_PASS'.*|define('DB_PASS', '${MARIADB_PASSWORD}');|g" $RSS_READER_PATH/config.php
|
sed -i "s|define('DB_PASS'.*|define('DB_PASS', '${MARIADB_PASSWORD}');|g" $RSS_READER_PATH/config.php
|
||||||
MARIADB_PASSWORD=
|
MARIADB_PASSWORD=
|
||||||
}
|
}
|
||||||
|
@ -245,7 +248,7 @@ function backup_remote_rss {
|
||||||
|
|
||||||
function restore_remote_rss {
|
function restore_remote_rss {
|
||||||
temp_restore_dir=/root/tempttrss
|
temp_restore_dir=/root/tempttrss
|
||||||
if grep -q "rss reader domain" $COMPLETION_FILE; then
|
if grep -q "rss reader domain" "$COMPLETION_FILE"; then
|
||||||
echo $"Restoring ttrss"
|
echo $"Restoring ttrss"
|
||||||
function_check get_mariadb_password
|
function_check get_mariadb_password
|
||||||
get_mariadb_password
|
get_mariadb_password
|
||||||
|
@ -263,6 +266,7 @@ function restore_remote_rss {
|
||||||
fi
|
fi
|
||||||
cp -r $temp_restore_dir/* /etc/share/tt-rss/
|
cp -r $temp_restore_dir/* /etc/share/tt-rss/
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 6391
|
exit 6391
|
||||||
fi
|
fi
|
||||||
|
@ -280,14 +284,14 @@ function restore_remote_rss {
|
||||||
function_check rss_modifications
|
function_check rss_modifications
|
||||||
rss_modifications
|
rss_modifications
|
||||||
|
|
||||||
if [ -d $SERVER_DIRECTORY/backup/ttrss ]; then
|
if [ -d "$SERVER_DIRECTORY/backup/ttrss" ]; then
|
||||||
chown -R www-data:www-data /etc/share/tt-rss
|
chown -R www-data:www-data /etc/share/tt-rss
|
||||||
fi
|
fi
|
||||||
if [ -d /root/tempttrss ]; then
|
if [ -d /root/tempttrss ]; then
|
||||||
rm -rf /root/tempttrss
|
rm -rf /root/tempttrss
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
|
MARIADB_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
|
||||||
sed -i "s|define('DB_PASS'.*|define('DB_PASS', '${MARIADB_PASSWORD}');|g" $RSS_READER_PATH/config.php
|
sed -i "s|define('DB_PASS'.*|define('DB_PASS', '${MARIADB_PASSWORD}');|g" $RSS_READER_PATH/config.php
|
||||||
MARIADB_PASSWORD=
|
MARIADB_PASSWORD=
|
||||||
|
|
||||||
|
@ -313,9 +317,9 @@ function remove_rss {
|
||||||
function_check drop_database
|
function_check drop_database
|
||||||
drop_database ttrss
|
drop_database ttrss
|
||||||
remove_completion_param install_rss
|
remove_completion_param install_rss
|
||||||
sed -i '/RSS /d' $COMPLETION_FILE
|
sed -i '/RSS /d' "$COMPLETION_FILE"
|
||||||
sed -i '/rss /d' $COMPLETION_FILE
|
sed -i '/rss /d' "$COMPLETION_FILE"
|
||||||
sed -i '/rss_/d' $COMPLETION_FILE
|
sed -i '/rss_/d' "$COMPLETION_FILE"
|
||||||
remove_backup_database_local ttrss
|
remove_backup_database_local ttrss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,15 +333,15 @@ function rss_modifications {
|
||||||
|
|
||||||
# ensure that socks5 proxy is used
|
# ensure that socks5 proxy is used
|
||||||
if ! grep -q "CURLPROXY_SOCKS5" $RSS_READER_PATH/plugins/af_unburn/init.php; then
|
if ! grep -q "CURLPROXY_SOCKS5" $RSS_READER_PATH/plugins/af_unburn/init.php; then
|
||||||
sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/plugins/af_unburn/init.php
|
sed -i "/curl_setopt(\$ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\\\t\\t\\t\\t\\tcurl_setopt(\$ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);" "$RSS_READER_PATH/plugins/af_unburn/init.php"
|
||||||
rss_modified=1
|
rss_modified=1
|
||||||
fi
|
fi
|
||||||
if ! grep -q "CURLPROXY_SOCKS5" $RSS_READER_PATH/include/functions.php; then
|
if ! grep -q "CURLPROXY_SOCKS5" $RSS_READER_PATH/include/functions.php; then
|
||||||
sed -i '/curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\t\t\t\tcurl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);' $RSS_READER_PATH/include/functions.php
|
sed -i "/curl_setopt(\$ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);/a \\\\t\\t\\t\\tcurl_setopt(\$ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);" "$RSS_READER_PATH/include/functions.php"
|
||||||
rss_modified=1
|
rss_modified=1
|
||||||
fi
|
fi
|
||||||
if [ $rss_modified ]; then
|
if [ $rss_modified ]; then
|
||||||
cd $RSS_READER_PATH
|
cd $RSS_READER_PATH || exit 564286428
|
||||||
git commit -a -m"Modify for Tor proxying"
|
git commit -a -m"Modify for Tor proxying"
|
||||||
fi
|
fi
|
||||||
chown -R www-data:www-data $RSS_READER_PATH
|
chown -R www-data:www-data $RSS_READER_PATH
|
||||||
|
@ -358,12 +362,12 @@ function install_rss_main {
|
||||||
if [ ! -d /etc/share ]; then
|
if [ ! -d /etc/share ]; then
|
||||||
mkdir /etc/share
|
mkdir /etc/share
|
||||||
fi
|
fi
|
||||||
cd /etc/share
|
cd /etc/share || exit 46284628
|
||||||
|
|
||||||
if [ -d /repos/rss ]; then
|
if [ -d /repos/rss ]; then
|
||||||
mkdir tt-rss
|
mkdir tt-rss
|
||||||
cp -r -p /repos/rss/. tt-rss
|
cp -r -p /repos/rss/. tt-rss
|
||||||
cd tt-rss
|
cd tt-rss || exit 462846822
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
|
@ -374,7 +378,7 @@ function install_rss_main {
|
||||||
echo $'Could not clone RSS reader repo'
|
echo $'Could not clone RSS reader repo'
|
||||||
exit 52925
|
exit 52925
|
||||||
fi
|
fi
|
||||||
cd $RSS_READER_PATH
|
cd $RSS_READER_PATH || exit 42479825792593
|
||||||
git checkout $RSS_READER_COMMIT -b $RSS_READER_COMMIT
|
git checkout $RSS_READER_COMMIT -b $RSS_READER_COMMIT
|
||||||
set_completion_param "rss reader commit" "$RSS_READER_COMMIT"
|
set_completion_param "rss reader commit" "$RSS_READER_COMMIT"
|
||||||
|
|
||||||
|
@ -397,151 +401,151 @@ function install_rss_main {
|
||||||
USE_V2_ONION_ADDRESS=1
|
USE_V2_ONION_ADDRESS=1
|
||||||
RSS_MOBILE_READER_ONION_HOSTNAME=$(add_onion_service mobilerss 80 ${RSS_MOBILE_READER_ONION_PORT})
|
RSS_MOBILE_READER_ONION_HOSTNAME=$(add_onion_service mobilerss 80 ${RSS_MOBILE_READER_ONION_PORT})
|
||||||
|
|
||||||
echo 'server {' > /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
{ echo 'server {';
|
||||||
echo " listen 127.0.0.1:$RSS_MOBILE_READER_ONION_PORT;" >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " listen 127.0.0.1:$RSS_MOBILE_READER_ONION_PORT;";
|
||||||
echo " server_name $RSS_MOBILE_READER_ONION_HOSTNAME;" >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " server_name $RSS_MOBILE_READER_ONION_HOSTNAME;";
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' root /etc/share/ttrss-mobile;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' root /etc/share/ttrss-mobile;';
|
||||||
echo ' index index.html index.php;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' index index.html index.php;';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location ~ \.php {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location / {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location / {';
|
||||||
echo ' try_files $uri $uri/ @ttrss;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " try_files \$uri \$uri/ @ttrss;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo ' location /tt-rss {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location /tt-rss {';
|
||||||
echo ' try_files $uri $uri/ @ttrss_base;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " try_files \$uri \$uri/ @ttrss_base;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location @ttrss {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location @ttrss {';
|
||||||
echo ' rewrite ^(.*)$ /index.html?p=$1 last;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " rewrite ^(.*)\$ /index.html?p=\$1 last;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo ' location @ttrss_base {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location @ttrss_base {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location ~ /\.(git) {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location ~ /\.(git) {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' add_header X-XSS-Protection "1; mode=block";' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-XSS-Protection "1; mode=block";';
|
||||||
echo ' add_header X-Robots-Tag none;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Robots-Tag none;';
|
||||||
echo ' add_header X-Download-Options noopen;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Download-Options noopen;';
|
||||||
echo ' add_header X-Permitted-Cross-Domain-Policies none;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Permitted-Cross-Domain-Policies none;';
|
||||||
echo ' add_header X-Frame-Options SAMEORIGIN;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Frame-Options SAMEORIGIN;';
|
||||||
echo ' add_header X-Content-Type-Options nosniff;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Content-Type-Options nosniff;';
|
||||||
echo ' client_max_body_size 15m;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' client_max_body_size 15m;';
|
||||||
echo '}' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '}';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo 'server {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo 'server {';
|
||||||
echo " listen 127.0.0.1:$RSS_READER_ONION_PORT default_server;" >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " listen 127.0.0.1:$RSS_READER_ONION_PORT default_server;";
|
||||||
echo " server_name $RSS_READER_ONION_HOSTNAME;" >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " server_name $RSS_READER_ONION_HOSTNAME;";
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' access_log /dev/null;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' root /etc/share/tt-rss;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' root /etc/share/tt-rss;';
|
||||||
echo ' index index.php;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' index index.php;';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location ~ \.php {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' fastcgi_read_timeout 30;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' fastcgi_read_timeout 30;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' set $mobile_rewrite do_not_perform;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " set \$mobile_rewrite do_not_perform;";
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' ## chi http_user_agent for mobile / smart phones ##' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' ## chi http_user_agent for mobile / smart phones ##';
|
||||||
echo ' if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino") {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " if (\$http_user_agent ~* \"(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino\") {";
|
||||||
echo ' set $mobile_rewrite perform;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " set \$mobile_rewrite perform;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-)") {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " if (\$http_user_agent ~* \"^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-)\") {";
|
||||||
echo ' set $mobile_rewrite perform;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " set \$mobile_rewrite perform;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' if ($mobile_rewrite = perform) {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " if (\$mobile_rewrite = perform) {";
|
||||||
echo " rewrite ^/(.*) http://$RSS_MOBILE_READER_ONION_HOSTNAME permanent;" >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " rewrite ^/(.*) http://$RSS_MOBILE_READER_ONION_HOSTNAME permanent;";
|
||||||
echo ' break;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' break;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location ~ \.php {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location ~ \.php {';
|
||||||
echo ' include snippets/fastcgi-php.conf;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' include snippets/fastcgi-php.conf;';
|
||||||
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location / {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location / {';
|
||||||
echo ' try_files $uri $uri/ @ttrss;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " try_files \$uri \$uri/ @ttrss;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location @ttrss {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location @ttrss {';
|
||||||
echo ' rewrite ^(.*)$ /index.php?p=$1 last;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo " rewrite ^(.*)\$ /index.php?p=\$1 last;";
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' location ~ /\.(git) {' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' location ~ /\.(git) {';
|
||||||
echo ' deny all;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' deny all;';
|
||||||
echo ' }' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' }';
|
||||||
echo '' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '';
|
||||||
echo ' add_header X-XSS-Protection "1; mode=block";' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-XSS-Protection "1; mode=block";';
|
||||||
echo ' add_header X-Robots-Tag none;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Robots-Tag none;';
|
||||||
echo ' add_header X-Download-Options noopen;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Download-Options noopen;';
|
||||||
echo ' add_header X-Permitted-Cross-Domain-Policies none;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Permitted-Cross-Domain-Policies none;';
|
||||||
echo ' add_header X-Frame-Options SAMEORIGIN;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Frame-Options SAMEORIGIN;';
|
||||||
echo ' add_header X-Content-Type-Options nosniff;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' add_header X-Content-Type-Options nosniff;';
|
||||||
echo ' client_max_body_size 15m;' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo ' client_max_body_size 15m;';
|
||||||
echo '}' >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
|
echo '}'; } > "/etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME"
|
||||||
|
|
||||||
if [ ! -f $RSS_READER_PATH/config.php ]; then
|
if [ ! -f $RSS_READER_PATH/config.php ]; then
|
||||||
# generate a config file
|
# generate a config file
|
||||||
RSS_FEED_CRYPT_KEY="$(create_password 24)"
|
RSS_FEED_CRYPT_KEY="$(create_password 24)"
|
||||||
echo '<?php' > $RSS_READER_PATH/config.php
|
{ echo '<?php';
|
||||||
echo " define('_CURL_HTTP_PROXY', '127.0.0.1:9050');" >> $RSS_READER_PATH/config.php
|
echo " define('_CURL_HTTP_PROXY', '127.0.0.1:9050');";
|
||||||
echo " define('DB_TYPE', 'mysql');" >> $RSS_READER_PATH/config.php
|
echo " define('DB_TYPE', 'mysql');";
|
||||||
echo " define('DB_HOST', 'localhost');" >> $RSS_READER_PATH/config.php
|
echo " define('DB_HOST', 'localhost');";
|
||||||
echo " define('DB_USER', 'root');" >> $RSS_READER_PATH/config.php
|
echo " define('DB_USER', 'root');";
|
||||||
echo " define('DB_NAME', 'ttrss');" >> $RSS_READER_PATH/config.php
|
echo " define('DB_NAME', 'ttrss');";
|
||||||
echo " define('DB_PASS', '${MARIADB_PASSWORD}');" >> $RSS_READER_PATH/config.php
|
echo " define('DB_PASS', '${MARIADB_PASSWORD}');";
|
||||||
echo " define('DB_PORT', '3306');" >> $RSS_READER_PATH/config.php
|
echo " define('DB_PORT', '3306');";
|
||||||
echo " define('MYSQL_CHARSET', 'UTF8');" >> $RSS_READER_PATH/config.php
|
echo " define('MYSQL_CHARSET', 'UTF8');";
|
||||||
echo " define('SELF_URL_PATH', 'http://${RSS_READER_ONION_HOSTNAME}/');" >> $RSS_READER_PATH/config.php
|
echo " define('SELF_URL_PATH', 'http://${RSS_READER_ONION_HOSTNAME}/');";
|
||||||
echo " define('FEED_CRYPT_KEY', '${RSS_FEED_CRYPT_KEY}');" >> $RSS_READER_PATH/config.php
|
echo " define('FEED_CRYPT_KEY', '${RSS_FEED_CRYPT_KEY}');";
|
||||||
echo " define('SINGLE_USER_MODE', false);" >> $RSS_READER_PATH/config.php
|
echo " define('SINGLE_USER_MODE', false);";
|
||||||
echo " define('SIMPLE_UPDATE_MODE', false);" >> $RSS_READER_PATH/config.php
|
echo " define('SIMPLE_UPDATE_MODE', false);";
|
||||||
echo " define('PHP_EXECUTABLE', '/usr/bin/php');" >> $RSS_READER_PATH/config.php
|
echo " define('PHP_EXECUTABLE', '/usr/bin/php');";
|
||||||
echo " define('LOCK_DIRECTORY', 'lock');" >> $RSS_READER_PATH/config.php
|
echo " define('LOCK_DIRECTORY', 'lock');";
|
||||||
echo " define('CACHE_DIR', 'cache');" >> $RSS_READER_PATH/config.php
|
echo " define('CACHE_DIR', 'cache');";
|
||||||
echo " define('ICONS_DIR', \"feed-icons\");" >> $RSS_READER_PATH/config.php
|
echo " define('ICONS_DIR', \"feed-icons\");";
|
||||||
echo " define('ICONS_URL', \"feed-icons\");" >> $RSS_READER_PATH/config.php
|
echo " define('ICONS_URL', \"feed-icons\");";
|
||||||
echo " define('AUTH_AUTO_CREATE', true);" >> $RSS_READER_PATH/config.php
|
echo " define('AUTH_AUTO_CREATE', true);";
|
||||||
echo " define('AUTH_AUTO_LOGIN', true);" >> $RSS_READER_PATH/config.php
|
echo " define('AUTH_AUTO_LOGIN', true);";
|
||||||
echo " define('FORCE_ARTICLE_PURGE', 0);" >> $RSS_READER_PATH/config.php
|
echo " define('FORCE_ARTICLE_PURGE', 0);";
|
||||||
echo " define('PUBSUBHUBBUB_HUB', '');" >> $RSS_READER_PATH/config.php
|
echo " define('PUBSUBHUBBUB_HUB', '');";
|
||||||
echo " define('PUBSUBHUBBUB_ENABLED', false);" >> $RSS_READER_PATH/config.php
|
echo " define('PUBSUBHUBBUB_ENABLED', false);";
|
||||||
echo " define('SPHINX_SERVER', 'localhost:9312');" >> $RSS_READER_PATH/config.php
|
echo " define('SPHINX_SERVER', 'localhost:9312');";
|
||||||
echo " define('SPHINX_INDEX', 'ttrss, delta');" >> $RSS_READER_PATH/config.php
|
echo " define('SPHINX_INDEX', 'ttrss, delta');";
|
||||||
echo " define('ENABLE_REGISTRATION', false);" >> $RSS_READER_PATH/config.php
|
echo " define('ENABLE_REGISTRATION', false);";
|
||||||
echo " define('REG_NOTIFY_ADDRESS', '${MY_EMAIL_ADDRESS}');" >> $RSS_READER_PATH/config.php
|
echo " define('REG_NOTIFY_ADDRESS', '${MY_EMAIL_ADDRESS}');";
|
||||||
echo " define('REG_MAX_USERS', 10);" >> $RSS_READER_PATH/config.php
|
echo " define('REG_MAX_USERS', 10);";
|
||||||
echo " define('SESSION_COOKIE_LIFETIME', 86400);" >> $RSS_READER_PATH/config.php
|
echo " define('SESSION_COOKIE_LIFETIME', 86400);";
|
||||||
echo " define('SMTP_FROM_NAME', 'Tiny Tiny RSS');" >> $RSS_READER_PATH/config.php
|
echo " define('SMTP_FROM_NAME', 'Tiny Tiny RSS');";
|
||||||
echo " define('SMTP_FROM_ADDRESS', 'noreply@${RSS_READER_ONION_HOSTNAME}');" >> $RSS_READER_PATH/config.php
|
echo " define('SMTP_FROM_ADDRESS', 'noreply@${RSS_READER_ONION_HOSTNAME}');";
|
||||||
echo " define('DIGEST_SUBJECT', '[tt-rss] New headlines for last 24 hours');" >> $RSS_READER_PATH/config.php
|
echo " define('DIGEST_SUBJECT', '[tt-rss] New headlines for last 24 hours');";
|
||||||
echo " define('SMTP_SERVER', '');" >> $RSS_READER_PATH/config.php
|
echo " define('SMTP_SERVER', '');";
|
||||||
echo " define('SMTP_LOGIN', '');" >> $RSS_READER_PATH/config.php
|
echo " define('SMTP_LOGIN', '');";
|
||||||
echo " define('SMTP_PASSWORD', '');" >> $RSS_READER_PATH/config.php
|
echo " define('SMTP_PASSWORD', '');";
|
||||||
echo " define('SMTP_SECURE', '');" >> $RSS_READER_PATH/config.php
|
echo " define('SMTP_SECURE', '');";
|
||||||
echo " define('CHECK_FOR_UPDATES', false);" >> $RSS_READER_PATH/config.php
|
echo " define('CHECK_FOR_UPDATES', false);";
|
||||||
echo " define('ENABLE_GZIP_OUTPUT', false);" >> $RSS_READER_PATH/config.php
|
echo " define('ENABLE_GZIP_OUTPUT', false);";
|
||||||
echo " define('PLUGINS', 'auth_internal, note, gnusocial');" >> $RSS_READER_PATH/config.php
|
echo " define('PLUGINS', 'auth_internal, note, gnusocial');";
|
||||||
echo " define('LOG_DESTINATION', 'sql');" >> $RSS_READER_PATH/config.php
|
echo " define('LOG_DESTINATION', 'sql');";
|
||||||
echo " define('CONFIG_VERSION', 26);" >> $RSS_READER_PATH/config.php
|
echo " define('CONFIG_VERSION', 26);"; } > $RSS_READER_PATH/config.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# initialize the database
|
# initialize the database
|
||||||
|
@ -569,28 +573,28 @@ function install_rss_main {
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
# daemon to update feeds
|
# daemon to update feeds
|
||||||
echo '[Unit]' > /etc/systemd/system/ttrss.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=ttrss_backend' >> /etc/systemd/system/ttrss.service
|
echo 'Description=ttrss_backend';
|
||||||
echo 'After=network.target mariadb.service' >> /etc/systemd/system/ttrss.service
|
echo 'After=network.target mariadb.service';
|
||||||
echo 'After=tor.service' >> /etc/systemd/system/ttrss.service
|
echo 'After=tor.service';
|
||||||
echo '' >> /etc/systemd/system/ttrss.service
|
echo '';
|
||||||
echo '[Service]' >> /etc/systemd/system/ttrss.service
|
echo '[Service]';
|
||||||
echo 'User=www-data' >> /etc/systemd/system/ttrss.service
|
echo 'User=www-data';
|
||||||
echo "ExecStart=/usr/bin/php $RSS_READER_PATH/update.php --daemon" >> /etc/systemd/system/ttrss.service
|
echo "ExecStart=/usr/bin/php $RSS_READER_PATH/update.php --daemon";
|
||||||
echo '' >> /etc/systemd/system/ttrss.service
|
echo '';
|
||||||
echo '[Install]' >> /etc/systemd/system/ttrss.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ttrss.service
|
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/ttrss.service
|
||||||
systemctl enable ttrss
|
systemctl enable ttrss
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl start ttrss
|
systemctl start ttrss
|
||||||
|
|
||||||
${PROJECT_NAME}-pass -u $MY_USERNAME -a rss -p "$RSS_READER_ADMIN_PASSWORD"
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a rss -p "$RSS_READER_ADMIN_PASSWORD"
|
||||||
|
|
||||||
install_completed rss_main
|
install_completed rss_main
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_rss_gnusocial {
|
function install_rss_gnusocial {
|
||||||
if [ ! $GNUSOCIAL_DOMAIN_NAME ]; then
|
if [ ! "$GNUSOCIAL_DOMAIN_NAME" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -608,19 +612,19 @@ function install_rss_gnusocial {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $INSTALL_DIR ]; then
|
if [ ! -d "$INSTALL_DIR" ]; then
|
||||||
mkdir -p $INSTALL_DIR
|
mkdir -p "$INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $INSTALL_DIR
|
cd "$INSTALL_DIR" || exit 7246284
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
git_clone $RSS_READER_GNUSOCIAL_REPO ttrss-gnusocial
|
git_clone $RSS_READER_GNUSOCIAL_REPO ttrss-gnusocial
|
||||||
if [ ! -d $INSTALL_DIR/ttrss-gnusocial ]; then
|
if [ ! -d "$INSTALL_DIR/ttrss-gnusocial" ]; then
|
||||||
echo $'Could not clone repo for RSS reader gnusocial plugin'
|
echo $'Could not clone repo for RSS reader gnusocial plugin'
|
||||||
exit 52838
|
exit 52838
|
||||||
fi
|
fi
|
||||||
cp -r $INSTALL_DIR/ttrss-gnusocial $RSS_READER_GNUSOCIAL_PATH
|
cp -r "$INSTALL_DIR/ttrss-gnusocial" $RSS_READER_GNUSOCIAL_PATH
|
||||||
cd $RSS_READER_GNUSOCIAL_PATH
|
cd "$RSS_READER_GNUSOCIAL_PATH" || exit 782462424
|
||||||
git checkout $RSS_READER_GNUSOCIAL_COMMIT -b $RSS_READER_GNUSOCIAL_COMMIT
|
git checkout $RSS_READER_GNUSOCIAL_COMMIT -b $RSS_READER_GNUSOCIAL_COMMIT
|
||||||
set_completion_param "rss reader gnusocial commit" "$RSS_READER_GNUSOCIAL_COMMIT"
|
set_completion_param "rss reader gnusocial commit" "$RSS_READER_GNUSOCIAL_COMMIT"
|
||||||
chown -R www-data:www-data $RSS_READER_GNUSOCIAL_PATH
|
chown -R www-data:www-data $RSS_READER_GNUSOCIAL_PATH
|
||||||
|
@ -642,8 +646,8 @@ function install_rss_mobile_reader {
|
||||||
# remove any previous install
|
# remove any previous install
|
||||||
if [ -d $RSS_READER_PATH/g2ttree-mobile ]; then
|
if [ -d $RSS_READER_PATH/g2ttree-mobile ]; then
|
||||||
if [[ $(is_completed "install_rss_mobile_reader") == "1" ]]; then
|
if [[ $(is_completed "install_rss_mobile_reader") == "1" ]]; then
|
||||||
sed -i '/install_rss_mobile_reader/d' $COMPLETION_FILE
|
sed -i '/install_rss_mobile_reader/d' "$COMPLETION_FILE"
|
||||||
sed -i '/rss mobile reader commit/d' $COMPLETION_FILE
|
sed -i '/rss mobile reader commit/d' "$COMPLETION_FILE"
|
||||||
rm -rf $RSS_READER_PATH/g2ttree-mobile
|
rm -rf $RSS_READER_PATH/g2ttree-mobile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -652,12 +656,12 @@ function install_rss_mobile_reader {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /etc/share
|
cd /etc/share || exit 7498264462
|
||||||
|
|
||||||
if [ -d /repos/rss-mobile ]; then
|
if [ -d /repos/rss-mobile ]; then
|
||||||
mkdir ttrss-mobile
|
mkdir ttrss-mobile
|
||||||
cp -r -p /repos/rss-mobile/. ttrss-mobile
|
cp -r -p /repos/rss-mobile/. ttrss-mobile
|
||||||
cd ttrss-mobile
|
cd ttrss-mobile || exit 462846284682
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
|
@ -668,7 +672,7 @@ function install_rss_mobile_reader {
|
||||||
echo $'Could not clone RSS mobile reader repo'
|
echo $'Could not clone RSS mobile reader repo'
|
||||||
exit 24816
|
exit 24816
|
||||||
fi
|
fi
|
||||||
cd $RSS_MOBILE_READER_PATH
|
cd "$RSS_MOBILE_READER_PATH" || exit 462846246824
|
||||||
git checkout $RSS_MOBILE_READER_COMMIT -b $RSS_MOBILE_READER_COMMIT
|
git checkout $RSS_MOBILE_READER_COMMIT -b $RSS_MOBILE_READER_COMMIT
|
||||||
set_completion_param "rss mobile reader commit" "$RSS_MOBILE_READER_COMMIT"
|
set_completion_param "rss mobile reader commit" "$RSS_MOBILE_READER_COMMIT"
|
||||||
|
|
||||||
|
|
|
@ -61,39 +61,44 @@ function scuttlebot_create_invite {
|
||||||
invite_string=$(su -c "sbot invite.create 1" - scuttlebot | sed 's/"//g')
|
invite_string=$(su -c "sbot invite.create 1" - scuttlebot | sed 's/"//g')
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo -e '\n\nYour Scuttlebot invite code is:\n\n'${invite_string}'\n\n'
|
echo -e "\\n\\nYour Scuttlebot invite code is:\\n\\n${invite_string}\\n\\n"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
read -n1 -r -p $"Press any key to continue..." key
|
read -n1 -r -p $"Press any key to continue..." key
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_interactive_scuttlebot {
|
function configure_interactive_scuttlebot {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(mktemp 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
dialog --backtitle $"Freedombone Control Panel" \
|
||||||
--title $"Scuttlebot" \
|
--title $"Scuttlebot" \
|
||||||
--radiolist $"Choose an operation:" 10 50 2 \
|
--radiolist $"Choose an operation:" 10 50 2 \
|
||||||
1 $"Create an invite" off \
|
1 $"Create an invite" off \
|
||||||
2 $"Exit" on 2> $data
|
2 $"Exit" on 2> "$data"
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
1) return;;
|
1) rm -f "$data"
|
||||||
255) return;;
|
return;;
|
||||||
|
255) rm -f "$data"
|
||||||
|
return;;
|
||||||
esac
|
esac
|
||||||
case $(cat $data) in
|
case $(cat "$data") in
|
||||||
1) scuttlebot_create_invite;;
|
1) scuttlebot_create_invite;;
|
||||||
2) break;;
|
2) rm -f "$data"
|
||||||
|
break;;
|
||||||
esac
|
esac
|
||||||
|
rm -f "$data"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_user_scuttlebot {
|
function remove_user_scuttlebot {
|
||||||
remove_username="$1"
|
echo -n ''
|
||||||
|
# remove_username="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_user_scuttlebot {
|
function add_user_scuttlebot {
|
||||||
new_username="$1"
|
# new_username="$1"
|
||||||
new_user_password="$2"
|
# new_user_password="$2"
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +114,8 @@ function install_interactive_scuttlebot {
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_password_scuttlebot {
|
function change_password_scuttlebot {
|
||||||
new_username="$1"
|
# new_username="$1"
|
||||||
new_user_password="$2"
|
# new_user_password="$2"
|
||||||
echo '0'
|
echo '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +128,7 @@ function reconfigure_scuttlebot {
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_scuttlebot {
|
function upgrade_scuttlebot {
|
||||||
if ! grep -q 'scuttlebot version:' $COMPLETION_FILE; then
|
if ! grep -q 'scuttlebot version:' $"COMPLETION_FILE"; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -134,11 +139,10 @@ function upgrade_scuttlebot {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
npm upgrade -g scuttlebot@${SCUTTLEBOT_VERSION} --save
|
if ! npm upgrade -g scuttlebot@${SCUTTLEBOT_VERSION} --save; then
|
||||||
if [ ! "$?" = "0" ]; then
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
sed -i "s|scuttlebot version.*|scuttlebot version:${SCUTTLEBOT_VERSION}|g" ${COMPLETION_FILE}
|
sed -i "s|scuttlebot version.*|scuttlebot version:${SCUTTLEBOT_VERSION}|g" "${COMPLETION_FILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup_local_scuttlebot {
|
function backup_local_scuttlebot {
|
||||||
|
@ -218,71 +222,72 @@ function remove_scuttlebot {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
remove_completion_param install_scuttlebot
|
remove_completion_param install_scuttlebot
|
||||||
sed -i '/scuttlebot /d' $COMPLETION_FILE
|
sed -i '/scuttlebot /d' "$COMPLETION_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_ssb_script {
|
function git_ssb_script {
|
||||||
if [[ "$1" == "mesh" ]]; then
|
if [[ "$1" == "mesh" ]]; then
|
||||||
|
# shellcheck disable=SC2154
|
||||||
git_ssb_script_name=$rootdir/usr/bin/git-ssb-create
|
git_ssb_script_name=$rootdir/usr/bin/git-ssb-create
|
||||||
git_ssb_daemon_filename=$rootdir/etc/systemd/system/git_ssb.service
|
git_ssb_daemon_filename=$rootdir/etc/systemd/system/git_ssb.service
|
||||||
else
|
else
|
||||||
git_ssb_script_name=/usr/bin/git-ssb-create
|
git_ssb_script_name=/usr/bin/git-ssb-create
|
||||||
git_ssb_daemon_filename=/etc/systemd/system/git_ssb.service
|
git_ssb_daemon_filename=/etc/systemd/system/git_ssb.service
|
||||||
fi
|
fi
|
||||||
echo '#!/bin/bash' > $git_ssb_script_name
|
{ echo '#!/bin/bash';
|
||||||
echo 'reponame="$1"' >> $git_ssb_script_name
|
echo "reponame=\"\$1\"";
|
||||||
echo '' >> $git_ssb_script_name
|
echo '';
|
||||||
echo 'if [[ "$reponame" != "" ]]; then' >> $git_ssb_script_name
|
echo "if [[ \"\$reponame\" != \"\" ]]; then";
|
||||||
echo ' mkdir $reponame' >> $git_ssb_script_name
|
echo " mkdir \$reponame";
|
||||||
echo ' cd $reponame' >> $git_ssb_script_name
|
echo " cd \$reponame";
|
||||||
echo ' git init' >> $git_ssb_script_name
|
echo ' git init';
|
||||||
echo ' git ssb create ssb $reponame' >> $git_ssb_script_name
|
echo " git ssb create ssb \$reponame";
|
||||||
echo ' git push --tags ssb master' >> $git_ssb_script_name
|
echo ' git push --tags ssb master';
|
||||||
echo 'fi' >> $git_ssb_script_name
|
echo 'fi';
|
||||||
echo 'exit 0' >> $git_ssb_script_name
|
echo 'exit 0'; } > $git_ssb_script_name
|
||||||
chmod +x $git_ssb_script_name
|
chmod +x $git_ssb_script_name
|
||||||
|
|
||||||
echo '[Unit]' > $git_ssb_daemon_filename
|
{ echo '[Unit]';
|
||||||
echo 'Description=Git SSB (SSB git web interface)' >> $git_ssb_daemon_filename
|
echo 'Description=Git SSB (SSB git web interface)';
|
||||||
echo 'After=syslog.target' >> $git_ssb_daemon_filename
|
echo 'After=syslog.target';
|
||||||
echo 'After=network.target' >> $git_ssb_daemon_filename
|
echo 'After=network.target';
|
||||||
echo 'After=scuttlebot.target' >> $git_ssb_daemon_filename
|
echo 'After=scuttlebot.target';
|
||||||
echo '' >> $git_ssb_daemon_filename
|
echo '';
|
||||||
echo '[Service]' >> $git_ssb_daemon_filename
|
echo '[Service]';
|
||||||
echo 'Type=simple' >> $git_ssb_daemon_filename
|
echo 'Type=simple';
|
||||||
echo 'User=scuttlebot' >> $git_ssb_daemon_filename
|
echo 'User=scuttlebot';
|
||||||
echo 'Group=scuttlebot' >> $git_ssb_daemon_filename
|
echo 'Group=scuttlebot';
|
||||||
echo "WorkingDirectory=/etc/scuttlebot" >> $git_ssb_daemon_filename
|
echo "WorkingDirectory=/etc/scuttlebot";
|
||||||
echo "ExecStart=/usr/bin/git ssb web --public localhost:$GIT_SSB_PORT" >> $git_ssb_daemon_filename
|
echo "ExecStart=/usr/bin/git ssb web --public localhost:$GIT_SSB_PORT";
|
||||||
echo 'Restart=always' >> $git_ssb_daemon_filename
|
echo 'Restart=always';
|
||||||
echo 'Environment="USER=scuttlebot"' >> $git_ssb_daemon_filename
|
echo 'Environment="USER=scuttlebot"';
|
||||||
echo '' >> $git_ssb_daemon_filename
|
echo '';
|
||||||
echo '[Install]' >> $git_ssb_daemon_filename
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> $git_ssb_daemon_filename
|
echo 'WantedBy=multi-user.target'; } > $git_ssb_daemon_filename
|
||||||
}
|
}
|
||||||
|
|
||||||
function scuttlebot_git_setup {
|
function scuttlebot_git_setup {
|
||||||
if [[ "$1" == "mesh" ]]; then
|
if [[ "$1" == "mesh" ]]; then
|
||||||
if [ ! -d $rootdir/usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight ]; then
|
if [ ! -d "$rootdir/usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight" ]; then
|
||||||
mkdir $rootdir/usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight
|
mkdir "$rootdir/usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight"
|
||||||
fi
|
fi
|
||||||
if [ ! -f $rootdir/usr/local/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css ]; then
|
if [ ! -f "$rootdir/usr/local/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css" ]; then
|
||||||
echo $'Could not find foundation.css'
|
echo $'Could not find foundation.css'
|
||||||
exit 347687245
|
exit 347687245
|
||||||
fi
|
fi
|
||||||
cp $rootdir/usr/local/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css $rootdir/usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight/foundation.css
|
cp "$rootdir/usr/local/lib/node_modules/git-ssb/node_modules/highlight.js/styles/foundation.css" "$rootdir/usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web/highlight/foundation.css"
|
||||||
|
|
||||||
git_ssb_nginx_site=$rootdir/etc/nginx/sites-available/git_ssb
|
git_ssb_nginx_site=$rootdir/etc/nginx/sites-available/git_ssb
|
||||||
echo 'server {' > $git_ssb_nginx_site
|
{ echo 'server {';
|
||||||
echo " listen $NGINX_GIT_SSB_PORT default_server;" >> $git_ssb_nginx_site
|
echo " listen $NGINX_GIT_SSB_PORT default_server;";
|
||||||
echo " server_name P${PEER_ID}.local;" >> $git_ssb_nginx_site
|
echo " server_name P${PEER_ID}.local;";
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '';
|
||||||
echo ' access_log /dev/null;' >> $git_ssb_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $git_ssb_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '';
|
||||||
echo ' add_header X-XSS-Protection "1; mode=block";' >> $git_ssb_nginx_site
|
echo ' add_header X-XSS-Protection "1; mode=block";';
|
||||||
echo ' add_header X-Content-Type-Options nosniff;' >> $git_ssb_nginx_site
|
echo ' add_header X-Content-Type-Options nosniff;';
|
||||||
echo ' add_header X-Frame-Options SAMEORIGIN;' >> $git_ssb_nginx_site
|
echo ' add_header X-Frame-Options SAMEORIGIN;'; } > "$git_ssb_nginx_site"
|
||||||
else
|
else
|
||||||
if [ ! $SCUTTLEBOT_DOMAIN_NAME ]; then
|
if [ ! $SCUTTLEBOT_DOMAIN_NAME ]; then
|
||||||
exit 7357225
|
exit 7357225
|
||||||
|
@ -300,15 +305,15 @@ function scuttlebot_git_setup {
|
||||||
git_ssb_nginx_site=/etc/nginx/sites-available/${SCUTTLEBOT_DOMAIN_NAME}
|
git_ssb_nginx_site=/etc/nginx/sites-available/${SCUTTLEBOT_DOMAIN_NAME}
|
||||||
function_check nginx_http_redirect
|
function_check nginx_http_redirect
|
||||||
nginx_http_redirect $SCUTTLEBOT_DOMAIN_NAME "index index.html"
|
nginx_http_redirect $SCUTTLEBOT_DOMAIN_NAME "index index.html"
|
||||||
echo 'server {' >> $git_ssb_nginx_site
|
{ echo 'server {';
|
||||||
echo ' listen 443 ssl;' >> $git_ssb_nginx_site
|
echo ' listen 443 ssl;';
|
||||||
echo ' #listen [::]:443 ssl;' >> $git_ssb_nginx_site
|
echo ' #listen [::]:443 ssl;';
|
||||||
echo " server_name $SCUTTLEBOT_DOMAIN_NAME;" >> $git_ssb_nginx_site
|
echo " server_name $SCUTTLEBOT_DOMAIN_NAME;";
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo ''; } >> $git_ssb_nginx_site
|
||||||
function_check nginx_compress
|
function_check nginx_compress
|
||||||
nginx_compress $SCUTTLEBOT_DOMAIN_NAME
|
nginx_compress $SCUTTLEBOT_DOMAIN_NAME
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '' >> "$git_ssb_nginx_site"
|
||||||
echo ' # Security' >> $git_ssb_nginx_site
|
echo ' # Security' >> "$git_ssb_nginx_site"
|
||||||
function_check nginx_ssl
|
function_check nginx_ssl
|
||||||
nginx_ssl $SCUTTLEBOT_DOMAIN_NAME
|
nginx_ssl $SCUTTLEBOT_DOMAIN_NAME
|
||||||
|
|
||||||
|
@ -316,45 +321,45 @@ function scuttlebot_git_setup {
|
||||||
nginx_disable_sniffing $SCUTTLEBOT_DOMAIN_NAME
|
nginx_disable_sniffing $SCUTTLEBOT_DOMAIN_NAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '' >> $git_ssb_nginx_site
|
{ echo '';
|
||||||
echo ' root /usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web;' >> $git_ssb_nginx_site
|
echo ' root /usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web;';
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '';
|
||||||
echo ' location = / {' >> $git_ssb_nginx_site
|
echo ' location = / {';
|
||||||
echo " proxy_pass http://localhost:${GIT_SSB_PORT};" >> $git_ssb_nginx_site
|
echo " proxy_pass http://localhost:${GIT_SSB_PORT};";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $git_ssb_nginx_site
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header Host $host;' >> $git_ssb_nginx_site
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $git_ssb_nginx_site
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_http_version 1.1;' >> $git_ssb_nginx_site
|
echo ' proxy_http_version 1.1;';
|
||||||
echo ' proxy_set_header Upgrade $http_upgrade;' >> $git_ssb_nginx_site
|
echo " proxy_set_header Upgrade \$http_upgrade;";
|
||||||
echo ' proxy_set_header Connection upgrade;' >> $git_ssb_nginx_site
|
echo ' proxy_set_header Connection upgrade;';
|
||||||
echo ' }' >> $git_ssb_nginx_site
|
echo ' }';
|
||||||
echo '}' >> $git_ssb_nginx_site
|
echo '}'; } >> $git_ssb_nginx_site
|
||||||
|
|
||||||
if [ $SCUTTLEBOT_ONION_HOSTNAME ]; then
|
if [ "$SCUTTLEBOT_ONION_HOSTNAME" ]; then
|
||||||
echo '' >> $git_ssb_nginx_site
|
{ echo '';
|
||||||
echo 'server {' >> $git_ssb_nginx_site
|
echo 'server {';
|
||||||
echo " listen 127.0.0.1:${SCUTTLEBOT_ONION_PORT} default_server;" >> $git_ssb_nginx_site
|
echo " listen 127.0.0.1:${SCUTTLEBOT_ONION_PORT} default_server;";
|
||||||
echo " server_name ${SCUTTLEBOT_ONION_HOSTNAME};" >> $git_ssb_nginx_site
|
echo " server_name ${SCUTTLEBOT_ONION_HOSTNAME};";
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '';
|
||||||
echo ' access_log /dev/null;' >> $git_ssb_nginx_site
|
echo ' access_log /dev/null;';
|
||||||
echo ' error_log /dev/null;' >> $git_ssb_nginx_site
|
echo ' error_log /dev/null;';
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '';
|
||||||
echo ' add_header X-XSS-Protection "1; mode=block";' >> $git_ssb_nginx_site
|
echo ' add_header X-XSS-Protection "1; mode=block";';
|
||||||
echo ' add_header X-Content-Type-Options nosniff;' >> $git_ssb_nginx_site
|
echo ' add_header X-Content-Type-Options nosniff;';
|
||||||
echo ' add_header X-Frame-Options SAMEORIGIN;' >> $git_ssb_nginx_site
|
echo ' add_header X-Frame-Options SAMEORIGIN;';
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '';
|
||||||
echo ' root /usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web;' >> $git_ssb_nginx_site
|
echo ' root /usr/local/lib/node_modules/git-ssb/node_modules/git-ssb-web;';
|
||||||
echo '' >> $git_ssb_nginx_site
|
echo '';
|
||||||
echo ' location = / {' >> $git_ssb_nginx_site
|
echo ' location = / {';
|
||||||
echo " proxy_pass http://localhost:${GIT_SSB_PORT};" >> $git_ssb_nginx_site
|
echo " proxy_pass http://localhost:${GIT_SSB_PORT};";
|
||||||
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $git_ssb_nginx_site
|
echo " proxy_set_header X-Real-IP \$remote_addr;";
|
||||||
echo ' proxy_set_header Host $host;' >> $git_ssb_nginx_site
|
echo " proxy_set_header Host \$host;";
|
||||||
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $git_ssb_nginx_site
|
echo " proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
|
||||||
echo ' proxy_http_version 1.1;' >> $git_ssb_nginx_site
|
echo ' proxy_http_version 1.1;';
|
||||||
echo ' proxy_set_header Upgrade $http_upgrade;' >> $git_ssb_nginx_site
|
echo " proxy_set_header Upgrade \$http_upgrade;";
|
||||||
echo ' proxy_set_header Connection upgrade;' >> $git_ssb_nginx_site
|
echo ' proxy_set_header Connection upgrade;';
|
||||||
echo ' }' >> $git_ssb_nginx_site
|
echo ' }';
|
||||||
echo '}' >> $git_ssb_nginx_site
|
echo '}'; } >> $git_ssb_nginx_site
|
||||||
fi
|
fi
|
||||||
if [[ "$1" != "mesh" ]]; then
|
if [[ "$1" != "mesh" ]]; then
|
||||||
nginx_ensite git_ssb
|
nginx_ensite git_ssb
|
||||||
|
@ -364,23 +369,23 @@ function scuttlebot_git_setup {
|
||||||
function mesh_install_dat {
|
function mesh_install_dat {
|
||||||
get_npm_arch
|
get_npm_arch
|
||||||
|
|
||||||
cat <<EOF > $rootdir/usr/bin/install_dat
|
cat <<EOF > "$rootdir/usr/bin/install_dat"
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
npm install --arch=$NPM_ARCH -g dat
|
npm install --arch=$NPM_ARCH -g dat
|
||||||
npm install --arch=$NPM_ARCH -g @garbados/dat-boi
|
npm install --arch=$NPM_ARCH -g @garbados/dat-boi
|
||||||
npm install --arch=$NPM_ARCH -g add-to-systemd
|
npm install --arch=$NPM_ARCH -g add-to-systemd
|
||||||
add-to-systemd dat-boi --user $(whoami) `which dat-boi`
|
add-to-systemd dat-boi --user "$(whoami)" "$(which dat-boi)"
|
||||||
EOF
|
EOF
|
||||||
chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
|
chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
|
||||||
chroot "$rootdir" /usr/bin/install_dat
|
chroot "$rootdir" /usr/bin/install_dat
|
||||||
rm $rootdir/usr/bin/install_dat
|
rm "$rootdir/usr/bin/install_dat"
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_dat {
|
function install_dat {
|
||||||
npm install -g dat
|
npm install -g dat
|
||||||
npm install -g @garbados/dat-boi
|
npm install -g @garbados/dat-boi
|
||||||
npm install -g add-to-systemd
|
npm install -g add-to-systemd
|
||||||
add-to-systemd dat-boi --user $(whoami) `which dat-boi`
|
add-to-systemd dat-boi --user "$(whoami)" "$(which dat-boi)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mesh_install_scuttlebot {
|
function mesh_install_scuttlebot {
|
||||||
|
@ -390,7 +395,7 @@ function mesh_install_scuttlebot {
|
||||||
|
|
||||||
get_npm_arch
|
get_npm_arch
|
||||||
|
|
||||||
cat <<EOF > $rootdir/usr/bin/install_scuttlebot
|
cat <<EOF > "$rootdir/usr/bin/install_scuttlebot"
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
npm install --arch=$NPM_ARCH -g scuttlebot@${SCUTTLEBOT_VERSION}
|
npm install --arch=$NPM_ARCH -g scuttlebot@${SCUTTLEBOT_VERSION}
|
||||||
npm install --arch=$NPM_ARCH -g git-ssb
|
npm install --arch=$NPM_ARCH -g git-ssb
|
||||||
|
@ -398,37 +403,37 @@ npm install --arch=$NPM_ARCH -g git-remote-ssb
|
||||||
EOF
|
EOF
|
||||||
chroot "$rootdir" /bin/chmod +x /usr/bin/install_scuttlebot
|
chroot "$rootdir" /bin/chmod +x /usr/bin/install_scuttlebot
|
||||||
chroot "$rootdir" /usr/bin/install_scuttlebot
|
chroot "$rootdir" /usr/bin/install_scuttlebot
|
||||||
rm $rootdir/usr/bin/install_scuttlebot
|
rm "$rootdir/usr/bin/install_scuttlebot"
|
||||||
|
|
||||||
if [ ! -f $rootdir/usr/local/bin/sbot ]; then
|
if [ ! -f "$rootdir/usr/local/bin/sbot" ]; then
|
||||||
echo $'Scuttlebot was not installed'
|
echo $'Scuttlebot was not installed'
|
||||||
exit 528253
|
exit 528253
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $rootdir/etc/scuttlebot ]; then
|
if [ ! -d "$rootdir/etc/scuttlebot" ]; then
|
||||||
mkdir -p $rootdir/etc/scuttlebot
|
mkdir -p "$rootdir/etc/scuttlebot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# an unprivileged user to run as
|
# an unprivileged user to run as
|
||||||
chroot "$rootdir" useradd -d /etc/scuttlebot/ scuttlebot
|
chroot "$rootdir" useradd -d /etc/scuttlebot/ scuttlebot
|
||||||
|
|
||||||
# daemon
|
# daemon
|
||||||
echo '[Unit]' > $rootdir/etc/systemd/system/scuttlebot.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=Scuttlebot (messaging system)' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'Description=Scuttlebot (messaging system)';
|
||||||
echo 'After=syslog.target' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'After=syslog.target';
|
||||||
echo 'After=network.target' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'After=network.target';
|
||||||
echo '' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo '';
|
||||||
echo '[Service]' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo '[Service]';
|
||||||
echo 'Type=simple' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'Type=simple';
|
||||||
echo 'User=scuttlebot' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'User=scuttlebot';
|
||||||
echo 'Group=scuttlebot' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'Group=scuttlebot';
|
||||||
echo "WorkingDirectory=/etc/scuttlebot" >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo "WorkingDirectory=/etc/scuttlebot";
|
||||||
echo 'ExecStart=/usr/local/bin/sbot server' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'ExecStart=/usr/local/bin/sbot server';
|
||||||
echo 'Restart=always' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'Restart=always';
|
||||||
echo 'Environment="USER=scuttlebot"' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'Environment="USER=scuttlebot"';
|
||||||
echo '' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo '';
|
||||||
echo '[Install]' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/scuttlebot.service
|
echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/scuttlebot.service"
|
||||||
|
|
||||||
scuttlebot_git_setup mesh
|
scuttlebot_git_setup mesh
|
||||||
git_ssb_script mesh
|
git_ssb_script mesh
|
||||||
|
@ -455,22 +460,22 @@ function install_scuttlebot {
|
||||||
useradd -d /etc/scuttlebot/ scuttlebot
|
useradd -d /etc/scuttlebot/ scuttlebot
|
||||||
|
|
||||||
# daemon
|
# daemon
|
||||||
echo '[Unit]' > /etc/systemd/system/scuttlebot.service
|
{ echo '[Unit]';
|
||||||
echo 'Description=Scuttlebot (messaging system)' >> /etc/systemd/system/scuttlebot.service
|
echo 'Description=Scuttlebot (messaging system)';
|
||||||
echo 'After=syslog.target' >> /etc/systemd/system/scuttlebot.service
|
echo 'After=syslog.target';
|
||||||
echo 'After=network.target' >> /etc/systemd/system/scuttlebot.service
|
echo 'After=network.target';
|
||||||
echo '' >> /etc/systemd/system/scuttlebot.service
|
echo '';
|
||||||
echo '[Service]' >> /etc/systemd/system/scuttlebot.service
|
echo '[Service]';
|
||||||
echo 'Type=simple' >> /etc/systemd/system/scuttlebot.service
|
echo 'Type=simple';
|
||||||
echo 'User=scuttlebot' >> /etc/systemd/system/scuttlebot.service
|
echo 'User=scuttlebot';
|
||||||
echo 'Group=scuttlebot' >> /etc/systemd/system/scuttlebot.service
|
echo 'Group=scuttlebot';
|
||||||
echo "WorkingDirectory=/etc/scuttlebot" >> /etc/systemd/system/scuttlebot.service
|
echo "WorkingDirectory=/etc/scuttlebot";
|
||||||
echo 'ExecStart=/usr/local/bin/sbot server' >> /etc/systemd/system/scuttlebot.service
|
echo 'ExecStart=/usr/local/bin/sbot server';
|
||||||
echo 'Restart=always' >> /etc/systemd/system/scuttlebot.service
|
echo 'Restart=always';
|
||||||
echo 'Environment="USER=scuttlebot"' >> /etc/systemd/system/scuttlebot.service
|
echo 'Environment="USER=scuttlebot"';
|
||||||
echo '' >> /etc/systemd/system/scuttlebot.service
|
echo '';
|
||||||
echo '[Install]' >> /etc/systemd/system/scuttlebot.service
|
echo '[Install]';
|
||||||
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/scuttlebot.service
|
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/scuttlebot.service
|
||||||
|
|
||||||
chown -R scuttlebot:scuttlebot /etc/scuttlebot
|
chown -R scuttlebot:scuttlebot /etc/scuttlebot
|
||||||
|
|
||||||
|
@ -489,24 +494,24 @@ function install_scuttlebot {
|
||||||
exit 73528
|
exit 73528
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '{' > /etc/scuttlebot/.ssb/config
|
{ echo '{';
|
||||||
echo " \"host\": \"${DEFAULT_DOMAIN_NAME}\"," >> /etc/scuttlebot/.ssb/config
|
echo " \"host\": \"${DEFAULT_DOMAIN_NAME}\",";
|
||||||
echo " \"port\": ${SCUTTLEBOT_PORT}," >> /etc/scuttlebot/.ssb/config
|
echo " \"port\": ${SCUTTLEBOT_PORT},";
|
||||||
echo ' "timeout": 30000,' >> /etc/scuttlebot/.ssb/config
|
echo ' "timeout": 30000,';
|
||||||
echo ' "pub": true,' >> /etc/scuttlebot/.ssb/config
|
echo ' "pub": true,';
|
||||||
echo ' "local": true,' >> /etc/scuttlebot/.ssb/config
|
echo ' "local": true,';
|
||||||
echo ' "friends": {' >> /etc/scuttlebot/.ssb/config
|
echo ' "friends": {';
|
||||||
echo ' "dunbar": 150,' >> /etc/scuttlebot/.ssb/config
|
echo ' "dunbar": 150,';
|
||||||
echo ' "hops": 3' >> /etc/scuttlebot/.ssb/config
|
echo ' "hops": 3';
|
||||||
echo ' },' >> /etc/scuttlebot/.ssb/config
|
echo ' },';
|
||||||
echo ' "gossip": {' >> /etc/scuttlebot/.ssb/config
|
echo ' "gossip": {';
|
||||||
echo ' "connections": 2' >> /etc/scuttlebot/.ssb/config
|
echo ' "connections": 2';
|
||||||
echo ' },' >> /etc/scuttlebot/.ssb/config
|
echo ' },';
|
||||||
echo ' "master": [],' >> /etc/scuttlebot/.ssb/config
|
echo ' "master": [],';
|
||||||
echo ' "logging": {' >> /etc/scuttlebot/.ssb/config
|
echo ' "logging": {';
|
||||||
echo ' "level": "error"' >> /etc/scuttlebot/.ssb/config
|
echo ' "level": "error"';
|
||||||
echo ' }' >> /etc/scuttlebot/.ssb/config
|
echo ' }';
|
||||||
echo '}' >> /etc/scuttlebot/.ssb/config
|
echo '}'; } > /etc/scuttlebot/.ssb/config
|
||||||
chown scuttlebot:scuttlebot /etc/scuttlebot/.ssb/config
|
chown scuttlebot:scuttlebot /etc/scuttlebot/.ssb/config
|
||||||
systemctl restart scuttlebot.service
|
systemctl restart scuttlebot.service
|
||||||
|
|
||||||
|
@ -527,10 +532,10 @@ function install_scuttlebot {
|
||||||
|
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
if ! grep -q "scuttlebot version:" ${COMPLETION_FILE}; then
|
if ! grep -q "scuttlebot version:" "${COMPLETION_FILE}"; then
|
||||||
echo "scuttlebot version:${SCUTTLEBOT_VERSION}" >> ${COMPLETION_FILE}
|
echo "scuttlebot version:${SCUTTLEBOT_VERSION}" >> "${COMPLETION_FILE}"
|
||||||
else
|
else
|
||||||
sed -i "s|scuttlebot version.*|scuttlebot version:${SCUTTLEBOT_VERSION}|g" ${COMPLETION_FILE}
|
sed -i "s|scuttlebot version.*|scuttlebot version:${SCUTTLEBOT_VERSION}|g" "${COMPLETION_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APP_INSTALLED=1
|
APP_INSTALLED=1
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue