Skip to content

Commit

Permalink
make all scripts much more readable (nextcloud#1493)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Hansson <[email protected]>
  • Loading branch information
szaimen and enoch85 authored Oct 14, 2020
1 parent 110b416 commit f28af08
Show file tree
Hide file tree
Showing 45 changed files with 593 additions and 346 deletions.
3 changes: 2 additions & 1 deletion addons/automatic_updates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ msg_box "This option will update your server every week on Saturdays at $AUT_UPD
The update will run the built in script '$SCRIPTS/update.sh' which will update both the server packages and Nextcloud itself.
You can read more about it here: https://www.techandme.se/nextcloud-update-is-now-fully-automated/
Please keep in mind that automatic updates might fail hence it's important to have a proper backup in place if you plan to run this option.
Please keep in mind that automatic updates might fail hence it's \
important to have a proper backup in place if you plan to run this option.
You can disable the automatic updates by entering the crontab file like this:
'sudo crontab -e -u root'
Expand Down
9 changes: 6 additions & 3 deletions addons/locate_mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ then
fi

# Check where the best mirrors are and update
msg_box "To make downloads as fast as possible when updating Ubuntu you should have download mirrors that are as close to you as possible.
msg_box "To make downloads as fast as possible when updating Ubuntu \
you should have download mirrors that are as close to you as possible.
Please note that there are no gurantees that the download mirrors this script will find are staying up for the lifetime of this server.
Please note that there are no gurantees that the download mirrors \
this script will find are staying up for the lifetime of this server.
Because of this, we don't recommend to change the mirror, except you live far away from the default mirror.
This is the method used: https://github.com/jblakeman/apt-select"
Expand All @@ -33,7 +35,8 @@ then
else
if [[ "$KEYBOARD_LAYOUT" =~ ,|/|_ ]]
then
msg_box "Your keymap contains more than one language, or a special character. ($KEYBOARD_LAYOUT)\nThis script can only handle one keymap at the time.\nThe default mirror ($REPO) will be kept."
msg_box "Your keymap contains more than one language, or a special character. ($KEYBOARD_LAYOUT)
This script can only handle one keymap at the time.\nThe default mirror ($REPO) will be kept."
exit 1
fi
print_text_in_color "$ICyan" "Locating the best mirrors..."
Expand Down
7 changes: 4 additions & 3 deletions addons/redis-server-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ debug_mode
root_check

# Check Ubuntu version
if ! version 16.04 "$DISTRO" 20.04.6; then
msg_box "Your current Ubuntu version is $DISTRO but must be between 16.04 - 20.04.6 to run this script."
msg_box "Please contact us to get support for upgrading your server:
if ! version 16.04 "$DISTRO" 20.04.6
then
msg_box "Your current Ubuntu version is $DISTRO but must be between 16.04 - 20.04.6 to run this script."
msg_box "Please contact us to get support for upgrading your server:
https://www.hanssonit.se/#contact
https://shop.hanssonit.se/"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions apps/adminer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ check_command a2ensite adminer.conf

if ! restart_webserver
then
msg_box "Apache2 could not restart...
msg_box "Apache2 could not restart...
The script will exit."
exit 1
else
msg_box "Adminer was sucessfully installed and can be reached here:
msg_box "Adminer was sucessfully installed and can be reached here:
https://$ADDRESS:9443
You can download more plugins and get more information here:
Expand Down
12 changes: 8 additions & 4 deletions apps/bitwarden-rs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ SUBDOMAIN=$(input_box_flow "Please enter the Domain that you want to use for Bit
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)

msg_box "Before continuing, please make sure that you have you have edited the DNS settings for $SUBDOMAIN, and opened port 80 and 443 directly to this servers IP. A full exstensive guide can be found here:
msg_box "Before continuing, please make sure that you have you have \
edited the DNS settings for $SUBDOMAIN, and opened port 80 and 443 \
directly to this servers IP. A full exstensive guide can be found here:
https://www.techandme.se/open-port-80-443
This can be done automatically if you have UNNP enabled in your firewall/router. You will be offered to use UNNP in the next step.
This can be done automatically if you have UNNP enabled in your firewall/router. \
You will be offered to use UNNP in the next step.
PLEASE NOTE:
Using other ports than the default 80 and 443 is not supported, though it may be possible with some custom modification:
Using other ports than the default 80 and 443 is not supported, \
though it may be possible with some custom modification:
https://help.nextcloud.com/t/domain-refused-to-connect-collabora/91303/17"

if yesno_box_no "Do you want to use UPNP to open port 80 and 443?"
Expand Down Expand Up @@ -279,7 +283,7 @@ check_command fail2ban-client reload

while :
do
msg_box "Bitwarden_rs with fail2ban have been sucessfully installed!
msg_box "Bitwarden_rs with fail2ban have been sucessfully installed!
Please visit https://$SUBDOMAIN/admin to manage all your settings.
Attention! Please note down the password for the admin panel: $ADMIN_PASS
Expand Down
2 changes: 1 addition & 1 deletion apps/bitwarden-rs_admin-panel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ case "$choice" in
fi
print_text_in_color "$ICyan" "Starting bitwarden_rs..."
docker start bitwarden_rs
msg_box "The admin-panel for Bitwarden_rs is now enabled.\n
msg_box "The admin-panel for Bitwarden_rs is now enabled.\n
Please note down the new admin-panel password: $ADMIN_PASS\n
Otherwise you will not be able to login to the admin-panel.\n
To change the password again, you can simply run this option (enable admin-panel) again."
Expand Down
34 changes: 27 additions & 7 deletions apps/bitwarden_mailconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ then
fi

# Enter mailserver
MAIL_SERVER=$(input_box_flow "Please enter the mailserver URL that you want to use.\nE.g. smtp.mail.de\nIf you don't want to change the mailserver, that is already configured inside the global.override.env-file, just leave the box empty.")
MAIL_SERVER=$(input_box_flow "Please enter the mailserver URL that you want to use.
E.g. smtp.mail.de\nIf you don't want to change the mailserver, that is already \
configured inside the global.override.env-file, just leave the box empty.")

# Enter if you want to use ssl
while :
do
PROTOCOL=$(input_box "Please type in the encryption protocol for your mailserver.\nThe available options are 'SSL', 'STARTTLS' or 'none'.\n\nIf you don't want to change the protocol setting, that are already configured inside the global.override.env-file, just leave the box empty.")
PROTOCOL=$(input_box "Please type in the encryption protocol for your mailserver.
The available options are 'SSL', 'STARTTLS' or 'none'.\n\nIf you don't want to change the protocol \
setting, that are already configured inside the global.override.env-file, just leave the box empty.")
if ! yesno_box_yes "Is this correct? $PROTOCOL"
then
msg_box "OK, please try again."
Expand Down Expand Up @@ -89,19 +93,35 @@ do
done

# Enter Port or just use standard port (defined by usage of ssl)
SMTP_PORT=$(input_box_flow "Please enter the port for your mailserver. The default port based on your protocol setting is $DEFAULT_PORT?\nPlease type that port into the inputbox, if you want to use it.\n\nIf you don't want to change the port, that is already configured inside the global.override.env-file, just leave the box empty.")
SMTP_PORT=$(input_box_flow "Please enter the port for your mailserver. The default port \
based on your protocol setting is $DEFAULT_PORT?\nPlease type that port into the inputbox, \
if you want to use it.\n\nIf you don't want to change the port, that is already configured \
inside the global.override.env-file, just leave the box empty.")

# Enter your mail username
MAIL_USERNAME=$(input_box_flow "Please enter the username for the login to your mail provider. E.g. [email protected]\nPlease note: the domain used for your mail username and the mailserver domain have to match!\nIf you don't want to change the mail username that is already configured inside the global.override.env-file, just leave the box empty.")
MAIL_USERNAME=$(input_box_flow "Please enter the username for the login to your mail provider.
E.g. [email protected]\nPlease note: the domain used for your mail username and the mailserver \
domain have to match!\nIf you don't want to change the mail username that is already configured \
inside the global.override.env-file, just leave the box empty.")

# Enter your mailuser password
MAIL_PASSWORD=$(input_box_flow "Please enter the password for your mailserver user.\nIf you don't want to change the password, that is already configured inside the global.override.env-file, just leave the box empty.")
MAIL_PASSWORD=$(input_box_flow "Please enter the password for your mailserver user.
If you don't want to change the password, that is already configured inside the \
global.override.env-file, just leave the box empty.")

# Enter admin mailadresses
ADMIN_ACCOUNT=$(input_box_flow "Please enter mailaccounts, that should have access to the Bitwarden admin-panel, reachable under https://your-bitwarden-domain/admin/.\nThey don't have to be registered Bitwarden accounts.\nTo make this setting work, your Bitwarden mailserver settings have to be correct.\nYou can enter just one e-mailaddress or enter more than one like so:\n'[email protected],[email protected],[email protected]'\nIf you want to keep the admin accounts that are already configured inside the global.override.env-file, just leave the box empty.")
ADMIN_ACCOUNT=$(input_box_flow "Please enter mailaccounts, that should have access \
to the Bitwarden admin-panel, reachable under https://your-bitwarden-domain/admin/.
They don't have to be registered Bitwarden accounts.
To make this setting work, your Bitwarden mailserver settings have to be correct.
You can enter just one e-mailaddress or enter more than one like so:
'[email protected],[email protected],[email protected]'
If you want to keep the admin accounts that are already configured inside the \
global.override.env-file, just leave the box empty.")

# Get results and store in a variable:
RESULT="These are the settings that will be changed in global.override.env. Please check that everything seems correct.\n\n"
RESULT="These are the settings that will be changed in global.override.env. \
Please check that everything seems correct.\n\n"
if [ -n "$MAIL_SERVER" ]
then
RESULT+="Mailserver URL=$MAIL_SERVER\n"
Expand Down
21 changes: 14 additions & 7 deletions apps/collabora_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ then
choice=$(whiptail --title "$TITLE" --menu \
"It seems like 'Collabora' is already installed.\nChoose what you want to do.
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Reinstall Collabora" "" \
"Uninstall Collabora" "" 3>&1 1>&2 2>&3)
"Reinstall Collabora" "" \
"Uninstall Collabora" "" 3>&1 1>&2 2>&3)

case "$choice" in
"Uninstall Collabora")
Expand Down Expand Up @@ -148,7 +148,10 @@ then
fi

# Ask for the domain for Collabora
SUBDOMAIN=$(input_box_flow "Collabora subdomain e.g: office.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
SUBDOMAIN=$(input_box_flow "Collabora subdomain e.g: office.yourdomain.com
NOTE: This domain must be different than your Nextcloud domain. \
They can however be hosted on the same server, but would require seperate DNS entries.")

# Nextcloud Main Domain
NCDOMAIN=$(nextcloud_occ_no_check config:system:get overwrite.cli.url | sed 's|https://||;s|/||')
Expand All @@ -164,13 +167,17 @@ source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercont
nc_update

# Notification
msg_box "Before continuing, please make sure that you have you have edited the DNS settings for $SUBDOMAIN, and opened port 80 and 443 directly to this servers IP. A full exstensive guide can be found here:
msg_box "Before continuing, please make sure that you have you have \
edited the DNS settings for $SUBDOMAIN, and opened port 80 and 443 \
directly to this servers IP. A full exstensive guide can be found here:
https://www.techandme.se/open-port-80-443
This can be done automatically if you have UNNP enabled in your firewall/router. You will be offered to use UNNP in the next step.
This can be done automatically if you have UNNP enabled in your firewall/router. \
You will be offered to use UNNP in the next step.
PLEASE NOTE:
Using other ports than the default 80 and 443 is not supported, though it may be possible with some custom modification:
Using other ports than the default 80 and 443 is not supported, \
though it may be possible with some custom modification:
https://help.nextcloud.com/t/domain-refused-to-connect-collabora/91303/17"

if yesno_box_no "Do you want to use UPNP to open port 80 and 443?"
Expand All @@ -188,7 +195,7 @@ apt update -q4 & spinner_loading
print_text_in_color "$ICyan" "Checking if Nextcloud is installed..."
if ! curl -s https://"$NCDOMAIN"/status.php | grep -q 'installed":true'
then
msg_box "It seems like Nextcloud is not installed or that you don't use https on:
msg_box "It seems like Nextcloud is not installed or that you don't use https on:
$NCDOMAIN.
Please install Nextcloud and make sure your domain is reachable, or activate TLS
on your domain to be able to run this script.
Expand Down
7 changes: 4 additions & 3 deletions apps/collabora_integrated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ check_nextcloud_https "Collabora (Integrated)"
# Check if Collabora is installed using the old method
if does_this_docker_exist 'collabora/code'
then
msg_box "Your server is compatible with the new way of installing Collabora. We will now remove the old docker and install the app from Nextcloud instead."
msg_box "Your server is compatible with the new way of installing Collabora. \
We will now remove the old docker and install the app from Nextcloud instead."
# Remove docker image
docker_prune_this 'collabora/code'
# Disable RichDocuments (Collabora App) if activated
Expand Down Expand Up @@ -84,8 +85,8 @@ then
choice=$(whiptail --title "$TITLE" --menu \
"It seems like 'Collabora' is already installed.\nChoose what you want to do.
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Reinstall Collabora" "" \
"Uninstall Collabora" "" 3>&1 1>&2 2>&3)
"Reinstall Collabora" "" \
"Uninstall Collabora" "" 3>&1 1>&2 2>&3)

case "$choice" in
"Uninstall Collabora")
Expand Down
7 changes: 4 additions & 3 deletions apps/fail2ban.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ then
choice=$(whiptail --title "$TITLE" --menu \
"It seems like 'Fail2Ban' is already installed.\nChoose what you want to do.
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Reinstall Fail2Ban" "" \
"Uninstall Fail2Ban" "" 3>&1 1>&2 2>&3)
"Reinstall Fail2Ban" "" \
"Uninstall Fail2Ban" "" 3>&1 1>&2 2>&3)

case "$choice" in
"Uninstall Fail2Ban")
Expand Down Expand Up @@ -92,7 +92,8 @@ do
if [ "$NCLOG" != "$VMLOGS/nextcloud.log" ]
then
# Might enter here if no OR multiple logs already exist, tidy up any existing logs and set the correct path
print_text_in_color "$ICyan" "Unexpected or non-existent logging configuration - deleting any discovered nextcloud.log files and creating a new one at $VMLOGS/nextcloud.log..."
print_text_in_color "$ICyan" "Unexpected or non-existent logging configuration - \
deleting any discovered nextcloud.log files and creating a new one at $VMLOGS/nextcloud.log..."
xargs rm -f <<< "$NCLOG"
# Set logging
nextcloud_occ config:system:set log_type --value=file
Expand Down
4 changes: 2 additions & 2 deletions apps/fulltextsearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ then
choice=$(whiptail --title "$TITLE" --menu \
"It seems like 'Fulltextsearch' is already installed.\nChoose what you want to do.
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Reinstall Fulltextsearch" "" \
"Uninstall Fulltextsearch" "" 3>&1 1>&2 2>&3)
"Reinstall Fulltextsearch" "" \
"Uninstall Fulltextsearch" "" 3>&1 1>&2 2>&3)

case "$choice" in
"Uninstall Fulltextsearch")
Expand Down
6 changes: 3 additions & 3 deletions apps/netdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ then
choice=$(whiptail --title "$TITLE" --menu \
"It seems like 'Netdata' is already installed.\nChoose what you want to do.
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Reinstall Netdata" "" \
"Uninstall Netdata" "" 3>&1 1>&2 2>&3)
"Reinstall Netdata" "" \
"Uninstall Netdata" "" 3>&1 1>&2 2>&3)

case "$choice" in
"Uninstall Netdata")
Expand Down Expand Up @@ -96,7 +96,7 @@ any_key "Please check information above and press any key to continue..."
# Installation done?
if [ -d /etc/netdata ]
then
msg_box "Netdata is now installed and can be accessed from this address:
msg_box "Netdata is now installed and can be accessed from this address:
http://$ADDRESS:19999
Expand Down
23 changes: 15 additions & 8 deletions apps/onlyoffice_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ then
choice=$(whiptail --title "$TITLE" --menu \
"It seems like 'Onlyoffice Docker' is already installed.\nChoose what you want to do.
$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
"Reinstall Onlyoffice Docker" "" \
"Uninstall Onlyoffice Docker" "" 3>&1 1>&2 2>&3)
"Reinstall Onlyoffice Docker" "" \
"Uninstall Onlyoffice Docker" "" 3>&1 1>&2 2>&3)

case "$choice" in
"Uninstall Onlyoffice Docker")
Expand Down Expand Up @@ -150,7 +150,8 @@ fi
# Check if apache2 evasive-mod is enabled and disable it because of compatibility issues
if [ "$(apache2ctl -M | grep evasive)" != "" ]
then
msg_box "We noticed that 'mod_evasive' is installed which is the DDOS protection for webservices. It has comptibility issues with OnlyOffice and you can now choose to disable it."
msg_box "We noticed that 'mod_evasive' is installed which is the DDOS protection for webservices. \
It has comptibility issues with OnlyOffice and you can now choose to disable it."
if ! yesno_box_yes "Do you want to disable DDOS protection?"
then
print_text_in_color "$ICyan" "Keeping mod_evasive active."
Expand All @@ -163,7 +164,9 @@ then
fi

# Ask for the domain for OnlyOffice
SUBDOMAIN=$(input_box_flow "OnlyOffice subdomain e.g: office.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
SUBDOMAIN=$(input_box_flow "OnlyOffice subdomain e.g: office.yourdomain.com
NOTE: This domain must be different than your Nextcloud domain. \
They can however be hosted on the same server, but would require seperate DNS entries.")

# Nextcloud Main Domain
NCDOMAIN=$(nextcloud_occ_no_check config:system:get overwrite.cli.url | sed 's|https://||;s|/||')
Expand All @@ -177,13 +180,17 @@ source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercont
nc_update

# Notification
msg_box "Before continuing, please make sure that you have you have edited the DNS settings for $SUBDOMAIN, and opened port 80 and 443 directly to this servers IP. A full exstensive guide can be found here:
msg_box "Before continuing, please make sure that you have you have \
edited the DNS settings for $SUBDOMAIN, and opened port 80 and 443 \
directly to this servers IP. A full exstensive guide can be found here:
https://www.techandme.se/open-port-80-443
This can be done automatically if you have UNNP enabled in your firewall/router. You will be offered to use UNNP in the next step.
This can be done automatically if you have UNNP enabled in your firewall/router. \
You will be offered to use UNNP in the next step.
PLEASE NOTE:
Using other ports than the default 80 and 443 is not supported, though it may be possible with some custom modification:
Using other ports than the default 80 and 443 is not supported, \
though it may be possible with some custom modification:
https://help.nextcloud.com/t/domain-refused-to-connect-collabora/91303/17"

if yesno_box_no "Do you want to use UPNP to open port 80 and 443?"
Expand All @@ -201,7 +208,7 @@ apt update -q4 & spinner_loading
print_text_in_color "$ICyan" "Checking if Nextcloud is installed..."
if ! curl -s https://"$NCDOMAIN"/status.php | grep -q 'installed":true'
then
msg_box "It seems like Nextcloud is not installed or that you don't use https on:
msg_box "It seems like Nextcloud is not installed or that you don't use https on:
$NCDOMAIN.
Please install Nextcloud and make sure your domain is reachable, or activate TLS
on your domain to be able to run this script.
Expand Down
Loading

0 comments on commit f28af08

Please sign in to comment.