Skip to content

Instantly share code, notes, and snippets.

@alexanderjackson
Last active March 16, 2017 07:03
Show Gist options
  • Save alexanderjackson/7e6fd01187327ffd8518 to your computer and use it in GitHub Desktop.
Save alexanderjackson/7e6fd01187327ffd8518 to your computer and use it in GitHub Desktop.
#/bin/bash
#set -x
# -------------------------------------------
# Save at /usr/local/sbin/seafile-server-change-address and set permissions with
# chmod 500 /usr/local/sbin/seafile-server-change-address
# -------------------------------------------
# -------------------------------------------
# Vars
# -------------------------------------------
HOSTNAME=$(hostname -f)
SEAFILE_DIR=/opt/seafile
# -------------------------------------------
# Intro
# -------------------------------------------
clear
cat <<EOF
Deutsch
-------------------------------------------
Mit diesem Skript können Sie die Adresse Ihres
Seafile Serves ändern. Das ist zum Beispiel nötig wenn
sich Ihre Domain- oder IP-Adresse geändert hat.
Wird Seafile mit der falschen Adresse betrieben,
funktioniert der Up- und Download von Dateien nicht.
Soll der Server mittes Portweiterleitung erreichbar
sein, verwenden Sie bitte die öffentliche oder externe
IP Ihres Routers bzw. einen öffentlich Domainnamen.
Bei Falscheingaben rufen Sie das Skript bitte erneut auf.
Der aktuelle Hostname wird vorausgefüllt. Ggf. einfach
ändern.
English
-------------------------------------------
With this script you can change the address of your
Seafile server. For example this is necessary if
your DNS or IP address has changed.
If the wrong address is set, up- and downloads will not work.
If the needs to be accessible from the WAN, but resides behind
a NAT router use the public IP or better the external DNS address.
If you made a mistake setting up the address, just run this skript again.
The current hostname is pre-populated. If necessary, simply change
it to fit your needs.
EOF
echo "Geben Sie jetzt die neue IP oder Domainadresse"
echo "Enter your new IP or DNS name"
read -e -p "Neue Domainadresse:" -i " ${HOSTNAME}" URL
cat <<EOF
Die eingebenen Adresse lautet: ${URL}
Your new address: ${URL}
-------------------------------------------
Fortfahren mit ENTER. Abruch mit STRG-C...
Proceed with ENTER. Abort with CTRL-C...
EOF
read dummy
clear
# -------------------------------------------
# Aendere Adressen in seahub_settings.py und ccnet.conf
# -------------------------------------------
sed -i "s/^SITE_BASE.*/SITE_BASE = \'${URL}\'/g" ${SEAFILE_DIR}/seahub_settings.py
sed -i "s/^SITE_NAME.*/SITE_NAME = \'${URL}\'/g" ${SEAFILE_DIR}/seahub_settings.py
sed -i "s/^SITE_TITLE.*/SITE_TITLE = \'${URL}\'/g" ${SEAFILE_DIR}/seahub_settings.py
sed -i "s/^FILE_SERVER_ROOT.*/FILE_SERVER_ROOT = '\https:\/\/${URL}\/seafhttp\'/g" ${SEAFILE_DIR}/seahub_settings.py
sed -i "s/^SERVICE_URL.*/SERVICE_URL = https:\/\/${URL}/g" ${SEAFILE_DIR}/ccnet/ccnet.conf
# -------------------------------------------
# Starte Seafile neu
# -------------------------------------------
service seafile-server restart
# -------------------------------------------
# Outro
# -------------------------------------------
cat <<EOF
Deutsch
-------------------------------------------
Fertig! Der Seafile Server wurde neu gestartet.
Seahub sollte nun über https://${HOSTNAME} erreichbar sein.
English
-------------------------------------------
Done! Your Seafile Server has been restarted.
Seahub should be reachable at https://${HOSTNAME}.
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment