From 032ccf6ef78cc33f283142d3df2eeb18625ffdbe Mon Sep 17 00:00:00 2001 From: sennewood <406414+sennewood@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:56:36 +0200 Subject: [PATCH 1/7] EDIT: correct script name --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 682f7b5..858996d 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ The script creates a `settings.conf` file for a standard Debian/Ubuntu Linux. ## Usage options -- Without any parameter: `./update-moodle` -- With new version: `./update-moodle 3.9` -- With new version + explicit download file: `./update-moodle 3.9 https://example.com/moodle-3.9.21.zip` +- Without any parameter: `./moodle-update` +- With new version: `./moodle-update 3.9` +- With new version + explicit download file: `./moodle-update 3.9 https://example.com/moodle-3.9.21.zip` ### Important information for Moodle 4 From d97b5580ffc11423305e7b6e284e9469ff4fe080 Mon Sep 17 00:00:00 2001 From: sennewood <406414+sennewood@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:03:50 +0200 Subject: [PATCH 2/7] ADD: set the needed moodle path --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 858996d..9e079d1 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ To automate __our environment__ we wrote this bash script. It may won't work in ## Setup 1. Clone this repository. 1. Make the script executable (if not cloned): `chmod +x moodle-update` +1. Go to your web directory: `cd /var/www` +1. Rename the moodle directory to: `moodle_x.y` like `moodle_4.01` +1. Create a link to this directory with the absolute path: `ln -s /var/www/moodle_4.01 moodle` +1. Tell your web server to serve `/var/www/moodle`. ### Config From 1804cc99f0416810a712a3eb793995e8f740f262 Mon Sep 17 00:00:00 2001 From: sennewood <406414+sennewood@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:11:39 +0100 Subject: [PATCH 3/7] ADD: format_topcoll handling --- moodle-update | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/moodle-update b/moodle-update index 240e08f..fba2f5d 100755 --- a/moodle-update +++ b/moodle-update @@ -472,6 +472,20 @@ printf "\n%-30s %s" "previous plugins" ": " # print array printf "${LIGHTCYAN}%d${NC}\n" "${#PLUGIN_DIFF_ARRAY[*]}" + # format_topcoll detection + if test -d "$BACKUP_PATH/course/format/topcoll/" + then + echo " " + printf "${LIGHTRED}%-30s${NC}\n" "format_topcoll detected" + printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " + read -r PLUGIN_FORMAT_TOPCOLL_URL + + printf "%-30s %s" "format_topcoll download" ": " + wget --quiet $PLUGIN_FORMAT_TOPCOLL_URL -O /tmp/format_topcoll.zip + checkstatus + echo " " + fi + # choose copy mode until test "$COPYALL" = "y" -o "$COPYALL" = "n" do @@ -507,6 +521,15 @@ printf "\n%-30s %s" "previous plugins" ": " cp -r $BACKUP_PATH/$PLUGIN_PATH/ $MOODLE_NEXT_PATH/${PLUGIN_PATH%/*} + + # copy format_topcoll + if test "$PLUGIN_PATH" = "course/format/topcoll" + then + rm -r $MOODLE_NEXT_PATH/course/format/topcoll + unzip -q /tmp/format_topcoll.zip -d $MOODLE_NEXT_PATH/course/format/topcoll + fi + + if test "$COPYALL" = "y" then printf "%-46s %s" "Copy $PLUGIN_PATH" ": " From f134baa2c8e3e5272f2c07f2aa02fea3cbfecd5d Mon Sep 17 00:00:00 2001 From: sennewood <406414+sennewood@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:36:23 +0100 Subject: [PATCH 4/7] FIX: format_topcoll unzip path --- moodle-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moodle-update b/moodle-update index fba2f5d..6e370b9 100755 --- a/moodle-update +++ b/moodle-update @@ -526,7 +526,7 @@ printf "\n%-30s %s" "previous plugins" ": " if test "$PLUGIN_PATH" = "course/format/topcoll" then rm -r $MOODLE_NEXT_PATH/course/format/topcoll - unzip -q /tmp/format_topcoll.zip -d $MOODLE_NEXT_PATH/course/format/topcoll + unzip -q /tmp/format_topcoll.zip -d $MOODLE_NEXT_PATH/course/format/ fi From a14a3ad9e3a96f930ba8af17552153fcada05bba Mon Sep 17 00:00:00 2001 From: sennewood <406414+sennewood@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:11:19 +0100 Subject: [PATCH 5/7] ADD: suggest download url for format_topcoll --- moodle-update | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/moodle-update b/moodle-update index 6e370b9..b97bc06 100755 --- a/moodle-update +++ b/moodle-update @@ -477,6 +477,28 @@ printf "\n%-30s %s" "previous plugins" ": " then echo " " printf "${LIGHTRED}%-30s${NC}\n" "format_topcoll detected" + + # suggest urls from: https://moodle.org/plugins/format_topcoll/versions + if test $MOODLE_VERSION_NEXT = "4.00" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29774/format_topcoll_moodle40_2022041703.zip" + elif test $MOODLE_VERSION_NEXT = "4.01" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29775/format_topcoll_moodle41_2022112602.zip" + elif test $MOODLE_VERSION_NEXT = "4.02" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29776/format_topcoll_moodle42_2023042401.zip" + elif test $MOODLE_VERSION_NEXT = "4.03" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/31376/format_topcoll_moodle43_2023100701.zip" + elif test $MOODLE_VERSION_NEXT = "4.04" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33218/format_topcoll_moodle44_2024032804.zip" + elif test $MOODLE_VERSION_NEXT = "4.05" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33614/format_topcoll_moodle45_2024092200.zip" + fi + printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " read -r PLUGIN_FORMAT_TOPCOLL_URL From 5c60fe587ecd621e9835f71202fd87bc939afa5b Mon Sep 17 00:00:00 2001 From: sennewood <406414+sennewood@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:50:27 +0100 Subject: [PATCH 6/7] ADD: boost_union handling --- moodle-update | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/moodle-update b/moodle-update index b97bc06..54963da 100755 --- a/moodle-update +++ b/moodle-update @@ -472,6 +472,44 @@ printf "\n%-30s %s" "previous plugins" ": " # print array printf "${LIGHTCYAN}%d${NC}\n" "${#PLUGIN_DIFF_ARRAY[*]}" + # boost_union detection + if test -d "$BACKUP_PATH/theme/boost_union/" + then + echo " " + printf "${LIGHTRED}%-30s${NC}\n" "boost_union detected" + + # suggest urls from: https://moodle.org/plugins/theme_boost_union/versions + if test $MOODLE_VERSION_NEXT = "4.00" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29678/theme_boost_union_moodle40_2022080940.zip" + elif test $MOODLE_VERSION_NEXT = "4.01" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33570/theme_boost_union_moodle41_2023010570.zip" + elif test $MOODLE_VERSION_NEXT = "4.02" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33569/theme_boost_union_moodle42_2023090147.zip" + elif test $MOODLE_VERSION_NEXT = "4.03" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33565/theme_boost_union_moodle43_2023102044.zip" + elif test $MOODLE_VERSION_NEXT = "4.04" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33590/theme_boost_union_moodle44_2024060103.zip" + elif test $MOODLE_VERSION_NEXT = "4.05" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33573/theme_boost_union_moodle45_2024100700.zip" + else + printf "%-30s %s\n" "get a download url from" ": https://moodle.org/plugins/theme_boost_union/versions" + fi + + printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " + read -r PLUGIN_BOOST_UNION_URL + + printf "%-30s %s" "boost_union download" ": " + wget --quiet $PLUGIN_BOOST_UNION_URL -O /tmp/boost_union.zip + checkstatus + echo " " + fi + # format_topcoll detection if test -d "$BACKUP_PATH/course/format/topcoll/" then @@ -497,6 +535,8 @@ printf "\n%-30s %s" "previous plugins" ": " elif test $MOODLE_VERSION_NEXT = "4.05" then printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33614/format_topcoll_moodle45_2024092200.zip" + else + printf "%-30s %s\n" "get a download url from" ": https://moodle.org/plugins/format_topcoll/versions" fi printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " @@ -549,8 +589,16 @@ printf "\n%-30s %s" "previous plugins" ": " then rm -r $MOODLE_NEXT_PATH/course/format/topcoll unzip -q /tmp/format_topcoll.zip -d $MOODLE_NEXT_PATH/course/format/ + rm /tmp/format_topcoll.zip fi + # copy boost_union + if test "$PLUGIN_PATH" = "theme/boost_union" + then + rm -r $MOODLE_NEXT_PATH/theme/boost_union + unzip -q /tmp/boost_union.zip -d $MOODLE_NEXT_PATH/theme/ + rm /tmp/boost_union.zip + fi if test "$COPYALL" = "y" then From 5f6f6e60d8c803d3a0177621f5dd8f6a7f93f199 Mon Sep 17 00:00:00 2001 From: sennewood <406414+sennewood@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:00:44 +0100 Subject: [PATCH 7/7] ADD: check if moodle minor version stays the same --- moodle-update | 165 +++++++++++++++++++++++++++----------------------- 1 file changed, 88 insertions(+), 77 deletions(-) diff --git a/moodle-update b/moodle-update index 54963da..93ea05d 100755 --- a/moodle-update +++ b/moodle-update @@ -472,82 +472,88 @@ printf "\n%-30s %s" "previous plugins" ": " # print array printf "${LIGHTCYAN}%d${NC}\n" "${#PLUGIN_DIFF_ARRAY[*]}" - # boost_union detection - if test -d "$BACKUP_PATH/theme/boost_union/" - then - echo " " - printf "${LIGHTRED}%-30s${NC}\n" "boost_union detected" - # suggest urls from: https://moodle.org/plugins/theme_boost_union/versions - if test $MOODLE_VERSION_NEXT = "4.00" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29678/theme_boost_union_moodle40_2022080940.zip" - elif test $MOODLE_VERSION_NEXT = "4.01" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33570/theme_boost_union_moodle41_2023010570.zip" - elif test $MOODLE_VERSION_NEXT = "4.02" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33569/theme_boost_union_moodle42_2023090147.zip" - elif test $MOODLE_VERSION_NEXT = "4.03" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33565/theme_boost_union_moodle43_2023102044.zip" - elif test $MOODLE_VERSION_NEXT = "4.04" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33590/theme_boost_union_moodle44_2024060103.zip" - elif test $MOODLE_VERSION_NEXT = "4.05" + # check if minor version changes + if test ! "$MOODLE_VERSION_NEXT" = "$MOODLE_VERSION_NOW" + then + # boost_union detection + if test -d "$BACKUP_PATH/theme/boost_union/" then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33573/theme_boost_union_moodle45_2024100700.zip" - else - printf "%-30s %s\n" "get a download url from" ": https://moodle.org/plugins/theme_boost_union/versions" - fi + echo " " + printf "${LIGHTRED}%-30s${NC}\n" "boost_union detected" - printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " - read -r PLUGIN_BOOST_UNION_URL + # suggest urls from: https://moodle.org/plugins/theme_boost_union/versions + if test $MOODLE_VERSION_NEXT = "4.00" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29678/theme_boost_union_moodle40_2022080940.zip" + elif test $MOODLE_VERSION_NEXT = "4.01" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33570/theme_boost_union_moodle41_2023010570.zip" + elif test $MOODLE_VERSION_NEXT = "4.02" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33569/theme_boost_union_moodle42_2023090147.zip" + elif test $MOODLE_VERSION_NEXT = "4.03" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33565/theme_boost_union_moodle43_2023102044.zip" + elif test $MOODLE_VERSION_NEXT = "4.04" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33590/theme_boost_union_moodle44_2024060103.zip" + elif test $MOODLE_VERSION_NEXT = "4.05" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33573/theme_boost_union_moodle45_2024100700.zip" + else + printf "%-30s %s\n" "get a download url from" ": https://moodle.org/plugins/theme_boost_union/versions" + fi - printf "%-30s %s" "boost_union download" ": " - wget --quiet $PLUGIN_BOOST_UNION_URL -O /tmp/boost_union.zip - checkstatus - echo " " - fi + printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " + read -r PLUGIN_BOOST_UNION_URL - # format_topcoll detection - if test -d "$BACKUP_PATH/course/format/topcoll/" - then - echo " " - printf "${LIGHTRED}%-30s${NC}\n" "format_topcoll detected" + printf "%-30s %s" "boost_union download" ": " + wget --quiet $PLUGIN_BOOST_UNION_URL -O /tmp/boost_union.zip + checkstatus + echo " " + fi - # suggest urls from: https://moodle.org/plugins/format_topcoll/versions - if test $MOODLE_VERSION_NEXT = "4.00" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29774/format_topcoll_moodle40_2022041703.zip" - elif test $MOODLE_VERSION_NEXT = "4.01" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29775/format_topcoll_moodle41_2022112602.zip" - elif test $MOODLE_VERSION_NEXT = "4.02" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29776/format_topcoll_moodle42_2023042401.zip" - elif test $MOODLE_VERSION_NEXT = "4.03" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/31376/format_topcoll_moodle43_2023100701.zip" - elif test $MOODLE_VERSION_NEXT = "4.04" - then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33218/format_topcoll_moodle44_2024032804.zip" - elif test $MOODLE_VERSION_NEXT = "4.05" + # format_topcoll detection + if test -d "$BACKUP_PATH/course/format/topcoll/" then - printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33614/format_topcoll_moodle45_2024092200.zip" - else - printf "%-30s %s\n" "get a download url from" ": https://moodle.org/plugins/format_topcoll/versions" - fi + echo " " + printf "${LIGHTRED}%-30s${NC}\n" "format_topcoll detected" - printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " - read -r PLUGIN_FORMAT_TOPCOLL_URL + # suggest urls from: https://moodle.org/plugins/format_topcoll/versions + if test $MOODLE_VERSION_NEXT = "4.00" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29774/format_topcoll_moodle40_2022041703.zip" + elif test $MOODLE_VERSION_NEXT = "4.01" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29775/format_topcoll_moodle41_2022112602.zip" + elif test $MOODLE_VERSION_NEXT = "4.02" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/29776/format_topcoll_moodle42_2023042401.zip" + elif test $MOODLE_VERSION_NEXT = "4.03" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/31376/format_topcoll_moodle43_2023100701.zip" + elif test $MOODLE_VERSION_NEXT = "4.04" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33218/format_topcoll_moodle44_2024032804.zip" + elif test $MOODLE_VERSION_NEXT = "4.05" + then + printf "%-30s %s\n" "suggested url" ": https://moodle.org/plugins/download.php/33614/format_topcoll_moodle45_2024092200.zip" + else + printf "%-30s %s\n" "get a download url from" ": https://moodle.org/plugins/format_topcoll/versions" + fi - printf "%-30s %s" "format_topcoll download" ": " - wget --quiet $PLUGIN_FORMAT_TOPCOLL_URL -O /tmp/format_topcoll.zip - checkstatus - echo " " + printf "${ORANGE}%-30s${NC} %s" "enter download url" ": " + read -r PLUGIN_FORMAT_TOPCOLL_URL + + printf "%-30s %s" "format_topcoll download" ": " + wget --quiet $PLUGIN_FORMAT_TOPCOLL_URL -O /tmp/format_topcoll.zip + checkstatus + echo " " + fi fi + # choose copy mode until test "$COPYALL" = "y" -o "$COPYALL" = "n" do @@ -584,21 +590,26 @@ printf "\n%-30s %s" "previous plugins" ": " cp -r $BACKUP_PATH/$PLUGIN_PATH/ $MOODLE_NEXT_PATH/${PLUGIN_PATH%/*} - # copy format_topcoll - if test "$PLUGIN_PATH" = "course/format/topcoll" + # check if minor version changes + if test ! "$MOODLE_VERSION_NEXT" = "$MOODLE_VERSION_NOW" then - rm -r $MOODLE_NEXT_PATH/course/format/topcoll - unzip -q /tmp/format_topcoll.zip -d $MOODLE_NEXT_PATH/course/format/ - rm /tmp/format_topcoll.zip + # copy format_topcoll + if test "$PLUGIN_PATH" = "course/format/topcoll" + then + rm -r $MOODLE_NEXT_PATH/course/format/topcoll + unzip -q /tmp/format_topcoll.zip -d $MOODLE_NEXT_PATH/course/format/ + rm /tmp/format_topcoll.zip + fi + + # copy boost_union + if test "$PLUGIN_PATH" = "theme/boost_union" + then + rm -r $MOODLE_NEXT_PATH/theme/boost_union + unzip -q /tmp/boost_union.zip -d $MOODLE_NEXT_PATH/theme/ + rm /tmp/boost_union.zip + fi fi - # copy boost_union - if test "$PLUGIN_PATH" = "theme/boost_union" - then - rm -r $MOODLE_NEXT_PATH/theme/boost_union - unzip -q /tmp/boost_union.zip -d $MOODLE_NEXT_PATH/theme/ - rm /tmp/boost_union.zip - fi if test "$COPYALL" = "y" then