Skip to content

Commit

Permalink
update the way scripts are run and downloaded (#1256)
Browse files Browse the repository at this point in the history
Co-authored-by: szaimen <[email protected]>
Co-authored-by: szaimen <[email protected]>
  • Loading branch information
3 people authored May 23, 2020
1 parent a81be89 commit b2c5d7d
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 93 deletions.
20 changes: 10 additions & 10 deletions apps/additional_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,42 @@ case "$choice" in
*"Fail2ban"*)
clear
print_text_in_color "$ICyan" "Downloading Fail2ban.sh..."
run_app_script fail2ban
run_script APP fail2ban
;;&
*"Adminer"*)
clear
print_text_in_color "$ICyan" "Downloading Adminer.sh..."
run_app_script adminer
run_script APP adminer
;;&
*"Netdata"*)
clear
print_text_in_color "$ICyan" "Downloading Netdata.sh..."
run_app_script netdata
run_script APP netdata
;;&
*"OnlyOffice"*)
clear
print_text_in_color "$ICyan" "Downloading OnlyOffice.sh..."
run_app_script onlyoffice
run_script APP onlyoffice
;;&
*"Collabora"*)
clear
print_text_in_color "$ICyan" "Downloading Collabora.sh..."
run_app_script collabora
run_script APP collabora
;;&
*"Bitwarden"*)
clear
print_text_in_color "$ICyan" "Downloading Bitwarden.sh..."
run_app_script tmbitwarden
run_script APP tmbitwarden
;;&
*"FullTextSearch"*)
clear
print_text_in_color "$ICyan" "Downloading FullTextSearch.sh..."
run_app_script fulltextsearch
run_script APP fulltextsearch
;;&
*"PreviewGenerator"*)
clear
print_text_in_color "$ICyan" "Downloading PreviewGenerator.sh..."
run_app_script previewgenerator
run_script APP previewgenerator
;;&
*"LDAP"*)
clear
Expand All @@ -84,12 +84,12 @@ case "$choice" in
*"Talk"*)
clear
print_text_in_color "$ICyan" "Downloading Talk.sh..."
run_app_script talk
run_script APP talk
;;&
*"SMB-mount"*)
clear
print_text_in_color "$ICyan" "Downloading SMB-mount.sh..."
run_app_script smbmount
run_script APP smbmount
;;&
*)
;;
Expand Down
2 changes: 1 addition & 1 deletion lets-encrypt/activate-tls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ check_open_port 80 "$TLSDOMAIN"
check_open_port 443 "$TLSDOMAIN"

# Fetch latest version of test-new-config.sh
check_command download_le_script test-new-config
check_command download_script LETS_ENC test-new-config

# Install certbot (Let's Encrypt)
install_certbot
Expand Down
2 changes: 1 addition & 1 deletion lets-encrypt/test-new-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ then
fi

# Set trusted domains
run_static_script trusted
run_script STATIC trusted

add_crontab_le() {
# shellcheck disable=SC2016
Expand Down
16 changes: 8 additions & 8 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ fi
# Warn user that HTTP/2 will be disabled if installing app that use Apache2 PHP instead of PHP-FPM
# E.g: http2_warn Modsecurity
http2_warn() {
msg_box "This VM has HTTP/2 enabled by default.
msg_box "This VM has HTTP/2 enabled by default.
If you continue with installing $1, HTTP/2 will be disabled since it's not compatible with the mpm module used by $1.
Expand Down Expand Up @@ -569,13 +569,13 @@ if lsb_release -sc | grep -ic "bionic" &> /dev/null || lsb_release -sc | grep -i
then
OS=1
elif lsb_release -i | grep -ic "Ubuntu" &> /dev/null
then
then
OS=1
elif uname -a | grep -ic "bionic" &> /dev/null || uname -a | grep -ic "focal" &> /dev/null
then
OS=1
elif uname -v | grep -ic "Ubuntu" &> /dev/null
then
then
OS=1
fi

Expand Down Expand Up @@ -845,7 +845,7 @@ download_script() {

# call like: run_script folder_variable name_of_script
# e.g. run_script APP additional_apps
# Use it for functions like run_static_script
# Use it for functions like run_script STATIC
run_script() {
rm -f "${SCRIPTS}/${2}.sh" "${SCRIPTS}/${2}.php" "${SCRIPTS}/${2}.py"
if download_script "${1}" "${2}"
Expand Down Expand Up @@ -965,15 +965,15 @@ or experience other issues then please report this to $ISSUES"
# rm master.zip*
# rm updater/ -R
# mv updater-master/ updater/
# download_static_script setup_secure_permissions_nextcloud -P $SCRIPTS
# download_script STATIC setup_secure_permissions_nextcloud -P $SCRIPTS
# bash $SECURE
# cd

# Do the upgrade
chown -R www-data:www-data "$NCPATH"
rm -rf "$NCPATH"/assets
yes | sudo -u www-data php /var/www/nextcloud/updater/updater.phar
download_static_script setup_secure_permissions_nextcloud -P $SCRIPTS
download_script STATIC setup_secure_permissions_nextcloud -P $SCRIPTS
bash $SECURE
occ_command maintenance:mode --off
fi
Expand All @@ -990,9 +990,9 @@ if [ "${CURRENTVERSION%%.*}" -ge "$1" ]
then
sleep 1
else
msg_box "Your current version are still not compatible with the version required to run this script.
msg_box "Your current version are still not compatible with the version required to run this script.
To upgrade between major versions, please check this out:
To upgrade between major versions, please check this out:
https://shop.hanssonit.se/product/upgrade-between-major-owncloud-nextcloud-versions/"
occ_command -V
exit
Expand Down
53 changes: 25 additions & 28 deletions nextcloud-startup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ then
fi

# Set locales
run_static_script locales
run_script STATIC locales

# Nextcloud 18 is required
lowest_compatible_nc 18
Expand All @@ -192,7 +192,7 @@ Please create a user with sudo permissions and the run this command:
sudo -u [user-with-sudo-permissions] sudo bash /var/scripts/nextcloud-startup-script.sh
We will do this for you when you hit OK."
download_static_script adduser
download_script STATIC adduser
bash $SCRIPTS/adduser.sh "$SCRIPTS/nextcloud-startup-script.sh"
rm $SCRIPTS/adduser.sh
else
Expand All @@ -209,7 +209,7 @@ please abort this script (CTRL+C) and report this issue to $ISSUES."
fi

# Upgrade mirrors
run_static_script locate_mirror
run_script STATIC locate_mirror

######## The first setup is OK to run to this point several times, but not any further ########
if [ -f "$SCRIPTS/you-can-not-run-the-startup-script-several-times" ]
Expand All @@ -235,25 +235,27 @@ touch "$SCRIPTS/you-can-not-run-the-startup-script-several-times"
echo
print_text_in_color "$ICyan" "Getting scripts from GitHub to be able to run the first setup..."
# Scripts in static (.sh, .php, .py)
download_static_script temporary-fix
download_static_script update
download_static_script trusted
download_static_script test_connection
download_static_script setup_secure_permissions_nextcloud
download_static_script change_db_pass
download_static_script nextcloud
download_static_script update-config
download_static_script apps
download_static_script configuration
download_le_script activate-tls
download_static_script menu
download_script LETS_ENC activate-tls
download_script STATIC temporary-fix
download_script STATIC update
download_script STATIC trusted
download_script STATIC test_connection
download_script STATIC setup_secure_permissions_nextcloud
download_script STATIC change_db_pass
download_script STATIC nextcloud
download_script STATIC update-config
download_script STATIC menu
download_script STATIC server_configuration
download_script STATIC nextcloud_configuration
download_script APP additional_apps

if home_sme_server
then
download_static_script nhss_index
download_script STATIC nhss_index
mv $SCRIPTS/nhss_index.php $HTML/index.php && rm -f $HTML/html/index.html
chmod 750 $HTML/index.php && chown www-data:www-data $HTML/index.php
else
download_static_script index
download_script STATIC index
mv $SCRIPTS/index.php $HTML/index.php && rm -f $HTML/html/index.html
chmod 750 $HTML/index.php && chown www-data:www-data $HTML/index.php
fi
Expand Down Expand Up @@ -364,10 +366,10 @@ clear
bash $SCRIPTS/server_configuration.sh

# Nextcloud configuration
bash $SCRIPTS/configuration.sh
bash $SCRIPTS/nextcloud_configuration.sh

# Install apps
bash $SCRIPTS/apps.sh
bash $SCRIPTS/additional_apps.sh

# Change passwords
# CLI USER
Expand Down Expand Up @@ -458,9 +460,9 @@ rm -f "$SCRIPTS/instruction.sh"
rm -f "$NCDATA/nextcloud.log"
rm -f "$SCRIPTS/static_ip.sh"
rm -f "$SCRIPTS/lib.sh"
rm -f "$SCRIPTS/configuration.sh"
rm -f "$SCRIPTS/apps.sh"
rm -f "$SCRIPTS/server_configuration.sh"
rm -f "$SCRIPTS/nextcloud_configuration.sh"
rm -f "$SCRIPTS/additional_apps.sh"

find /root "/home/$UNIXUSER" -type f \( -name '*.sh*' -o -name '*.html*' -o -name '*.tar*' -o -name 'results' -o -name '*.zip*' \) -delete
find "$NCPATH" -type f \( -name 'results' -o -name '*.sh*' \) -delete
Expand Down Expand Up @@ -512,13 +514,8 @@ apt autoremove -y
apt autoclean

# Set trusted domain in config.php
if [ -f "$SCRIPTS"/trusted.sh ]
then
bash "$SCRIPTS"/trusted.sh
rm -f "$SCRIPTS"/trusted.sh
else
run_static_script trusted
fi
bash $SCRIPTS/trusted.sh
rm -f $SCRIPTS/trusted.sh

# Success!
msg_box "Congratulations! You have successfully installed Nextcloud!
Expand Down
Loading

0 comments on commit b2c5d7d

Please sign in to comment.