-
-
Save okpedro/79e3b4243c09b002f10ffe9d37b2a9a1 to your computer and use it in GitHub Desktop.
Free ports 80 and 443 on Synology NAS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# NEWLY ADDED BACKUP FUNCTIONALITY IS NOT FULLY TESTED YET, USE WITH CARE, ESPECIALLY DELETION | |
# Steps to install | |
# Save this script in one of your shares | |
# Backup /usr/syno/share/nginx/ as follows: | |
# # cd /usr/syno/share/ | |
# # tar cvf ~/nginx.tar nginx | |
# Run this script as root | |
# Reboot and ensure everything is still working | |
# If not, restore the backup and post a comment on this script's gist page | |
# If it did, schedule it to run at boot | |
# through Control Panel -> Task Scheduler | |
HTTP_PORT=81 | |
HTTPS_PORT=444 | |
BACKUP_FILES=false | |
BACKUP_DIR=/volume1/apps/free_ports/backup | |
DELETE_OLD_BACKUPS=false | |
KEEP_BACKUP_DAYS=30 | |
DATE=$(date +%Y-%m-%d-%H-%m-%S) | |
if [ "$BACKUP_FILES" == "true" ]; then | |
mkdir -p "$BACKUP_DIR/$DATE" | |
cp /usr/syno/share/nginx/*.mustache "$BACKUP_DIR/$DATE" | |
fi | |
if [ "$DELETE_OLD_BACKUPS" == "true" ]; then | |
find "$BACKUP_DIR/" -type d -mtime +$KEEP_BACKUP_DAYS -exec rm -r {} \; | |
fi | |
sed -i "s/^\([ \t]\+listen[ \t]\+[]:[]*\)80\([^0-9]\)/\1$HTTP_PORT\2/" /usr/syno/share/nginx/*.mustache | |
sed -i "s/^\([ \t]\+listen[ \t]\+[]:[]*\)443\([^0-9]\)/\1$HTTPS_PORT\2/" /usr/syno/share/nginx/*.mustache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment