[shellcheck] Fix ShellCheck issues

Detected on the CI we are testing.
mejoras_instalacion
Evilham 2022-08-30 14:41:19 +02:00
parent 5bb3afe2aa
commit 52f99c38bb
No known key found for this signature in database
GPG Key ID: AE3EE30D970886BF
1 changed files with 80 additions and 70 deletions

150
dd-ctl
View File

@ -79,9 +79,9 @@ Generate .orig and .patch files to compare with upstream: ./dd-ctl genpatches
# Help messages
if [ -z "$OPERATION" ] || [ "$OPERATION" = "-h" ] || [ "$OPERATION" = "--help" ]; then
test -n "$OPERATION" || printf "Missing command.\n\n"
help
exit
test -n "$OPERATION" || printf "Missing command.\n\n"
help
exit
fi
# Sanity checks
@ -191,7 +191,7 @@ build_compose(){
ln -sf "${CUSTOM_PATH}/.env" dd-sso/docker-compose-parts/.env
# Clean up older custom data
rm -rf custom/system/keycloak-themes
rm -rf custom/system/keycloak-themes
rmdir custom/system 2>/dev/null || true
if [ "$BEHIND_PROXY" = "true" ]; then
@ -225,6 +225,7 @@ listpatches(){
# Generate .orig and .patch files with ./dd-ctl genpatches
# file license author url
EOM
# shellcheck disable=SC2044 # TODO: Get rid of this for X in find
for patchfile in $(find . -name 'dd-patch'); do
patchdir="$(dirname "${patchfile}")"
grep -vE '^#' "${patchfile}" | awk "{print \"${patchdir}/\" \$0}"
@ -233,7 +234,9 @@ listpatches(){
genpatches(){
CD="$(pwd)"
# shellcheck disable=SC2044 # TODO: Get rid of this for X in find
for patchfile in $(find . -name 'dd-patch'); do
# shellcheck disable=SC2164 # We got the dir from find
cd "$(dirname "${patchfile}")"
echo "IN DIR $(pwd)"
grep -vE '^#' dd-patch | while IFS= read -r line; do
@ -242,7 +245,7 @@ genpatches(){
wget "${url}" -O "${fn}.orig"
diff "${fn}.orig" "${fn}" > "${fn}.patch"
done
# shellcheck disable=SC2164 # This was previous working dir
cd "${CD}"
done
}
@ -382,7 +385,7 @@ setup_nextcloud(){
# OnlyOffice
php occ --no-warnings config:app:set -n onlyoffice preview --value="true"
php occ --no-warnings config:app:set -n onlyoffice defFormats --value="{\"csv\":\"false\",\"doc\":\"true\",\"docm\":\"false\",\"docx\":\"true\",\"docxf\":\"true\",\"oform\":\"true\",\"dotx\":\"false\",\"epub\":\"false\",\"html\":\"false\",\"odp\":\"true\",\"ods\":\"true\",\"odt\":\"true\",\"otp\":\"true\",\"ots\":\"true\",\"ott\":\"true\",\"pdf\":\"false\",\"potm\":\"false\",\"potx\":\"false\",\"ppsm\":\"false\",\"ppsx\":\"true\",\"ppt\":\"true\",\"pptm\":\"false\",\"pptx\":\"true\",\"rtf\":\"false\",\"txt\":\"false\",\"xls\":\"true\",\"xlsm\":\"false\",\"xlsx\":\"true\",\"xltm\":\"false\",\"xltx\":\"true\"}",
php occ --no-warnings config:app:set -n onlyoffice editFormats --value="{\"csv\":\"true\",\"odp\":\"false\",\"ods\":\"false\",\"odt\":\"false\",\"rtf\":\"false\",\"txt\":\"true\"}"
php occ --no-warnings config:app:set -n onlyoffice editFormats --value="{\"csv\":\"true\",\"odp\":\"false\",\"ods\":\"false\",\"odt\":\"false\",\"rtf\":\"false\",\"txt\":\"true\"}"
EOF
@ -411,8 +414,8 @@ setup_nextcloud(){
docker exec dd-apps-nextcloud-app sed -i 's/encodeURIComponent(i\[a\])/i[a]/' /var/www/html/apps/files_pdfviewer/js/files_pdfviewer-main.js
# Add default file for moodle activities
if [ ! -f $DATA_FOLDER/nextcloud/admin/files/template.docx ]; then
cp dd-apps/docker/nextcloud/template.docx $DATA_FOLDER/nextcloud/admin/files/
if [ ! -f "$DATA_FOLDER/nextcloud/admin/files/template.docx" ]; then
cp dd-apps/docker/nextcloud/template.docx "$DATA_FOLDER/nextcloud/admin/files/"
nextcloud_scan
fi
@ -494,7 +497,7 @@ saml_certificates(){
wait_for_moodle(){
echo "Waiting for system to be fully up before customizing... It can take some minutes..."
echo " (you can monitorize install with: docker logs dd-apps-moodle --follow"
while [ "`docker inspect -f {{.State.Health.Status}} dd-apps-moodle`" != "healthy" ]; do sleep 2; done
while ! docker inspect -f '{{.State.Health.Status}}' dd-apps-moodle | grep -q "healthy"; do sleep 2; done
}
upgrade_moodle(){
@ -532,9 +535,10 @@ extras_nextcloud_set_admin_group(){
}
extras_dump_keycloak_client(){
docker exec -ti dd-sso-keycloak sh -c "
docker exec -i dd-sso-keycloak sh -s <<-EOF
/opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password keycloakkeycloak \
&& /opt/jboss/keycloak/bin/kcadm.sh get clients/bef873f0-2079-4876-8657-067de27d01b7 -r master"""
&& /opt/jboss/keycloak/bin/kcadm.sh get clients/bef873f0-2079-4876-8657-067de27d01b7 -r master
EOF
}
upgrade_plugins_moodle(){
wait_for_moodle
@ -546,21 +550,21 @@ upgrade_plugins_moodle(){
mkdir -p /tmp/moodle/theme/cbe
mkdir -p /tmp/moodle/blocks
curl --location "${MOODLE_PLUGIN_JITSI_OVERRIDE:-https://moodle.org/plugins/download.php/27002/mod_jitsi_moodle40_2022070602.zip}" > jitsi.zip
unzip jitsi.zip -d /tmp/moodle/mod/
rm jitsi.zip
curl --location "${MOODLE_PLUGIN_BBB_OVERRIDE:-https://moodle.org/plugins/download.php/26792/mod_bigbluebuttonbn_moodle311_2019101014.zip}" > bbb.zip
unzip bbb.zip -d /tmp/moodle/mod/
rm bbb.zip
# curl --location https://github.com/isard-vdi/moodle-auth_saml2/archive/refs/heads/role_map.zip > auth_saml2.zip
curl --location "${MOODLE_PLUGIN_JITSI_OVERRIDE:-https://moodle.org/plugins/download.php/27002/mod_jitsi_moodle40_2022070602.zip}" > jitsi.zip
unzip jitsi.zip -d /tmp/moodle/mod/
rm jitsi.zip
curl --location "${MOODLE_PLUGIN_BBB_OVERRIDE:-https://moodle.org/plugins/download.php/26792/mod_bigbluebuttonbn_moodle311_2019101014.zip}" > bbb.zip
unzip bbb.zip -d /tmp/moodle/mod/
rm bbb.zip
# curl --location https://github.com/isard-vdi/moodle-auth_saml2/archive/refs/heads/role_map.zip > auth_saml2.zip
# curl --location https://moodle.org/plugins/download.php/24556/auth_saml2_moodle311_2021062900.zip > auth_saml2.zip
curl --location "${MOODLE_PLUGIN_SAML_OVERRIDE:-https://github.com/isard-vdi/moodle-auth_saml2/archive/refs/heads/role_map.zip}" > auth_saml2.zip
unzip auth_saml2.zip -d /tmp/moodle/auth/
mv /tmp/moodle/auth/moodle-auth_saml2-role_map/* /tmp/moodle/auth/saml2/
rm -rf /tmp/moodle/auth/moodle-auth_saml2-role_map
rm auth_saml2.zip
unzip auth_saml2.zip -d /tmp/moodle/auth/
mv /tmp/moodle/auth/moodle-auth_saml2-role_map/* /tmp/moodle/auth/saml2/
rm -rf /tmp/moodle/auth/moodle-auth_saml2-role_map
rm auth_saml2.zip
M3IPSHARE="https://github.com/3iPunt/moodle_mod_tresipuntshare/archive/refs/heads/master.zip"
if [[ "${MOODLE_PLUGIN_TRESIPUNTSHARE_OVERRIDE:-${M3IPSHARE}}" == *"develop"* ]]; then
@ -568,10 +572,10 @@ upgrade_plugins_moodle(){
else
PLUGIN_BRANCH=master
fi
curl --location "${MOODLE_PLUGIN_TRESIPUNTSHARE_OVERRIDE:-${M3IPSHARE}}" > tresipuntshare.zip
unzip tresipuntshare.zip -d /tmp/moodle/mod/
mv /tmp/moodle/mod/moodle_mod_tresipuntshare-$PLUGIN_BRANCH /tmp/moodle/mod/tresipuntshare
rm tresipuntshare.zip
curl --location "${MOODLE_PLUGIN_TRESIPUNTSHARE_OVERRIDE:-${M3IPSHARE}}" > tresipuntshare.zip
unzip tresipuntshare.zip -d /tmp/moodle/mod/
mv /tmp/moodle/mod/moodle_mod_tresipuntshare-$PLUGIN_BRANCH /tmp/moodle/mod/tresipuntshare
rm tresipuntshare.zip
M3IPVIDEO="https://github.com/3iPunt/moodle_mod_tresipuntvideo/archive/refs/heads/master.zip"
if [[ "${MOODLE_PLUGIN_TRESIPUNTVIDEO_OVERRIDE:-${M3IPVIDEO}}" == *"develop"* ]]; then
@ -579,10 +583,10 @@ upgrade_plugins_moodle(){
else
PLUGIN_BRANCH=master
fi
curl --location "${MOODLE_PLUGIN_TRESIPUNTVIDEO_OVERRIDE:-${M3IPVIDEO}}" > tresipuntvideo.zip
unzip tresipuntvideo.zip -d /tmp/moodle/mod/
mv /tmp/moodle/mod/moodle_mod_tresipuntvideo-$PLUGIN_BRANCH /tmp/moodle/mod/tresipuntvideo
rm tresipuntvideo.zip
curl --location "${MOODLE_PLUGIN_TRESIPUNTVIDEO_OVERRIDE:-${M3IPVIDEO}}" > tresipuntvideo.zip
unzip tresipuntvideo.zip -d /tmp/moodle/mod/
mv /tmp/moodle/mod/moodle_mod_tresipuntvideo-$PLUGIN_BRANCH /tmp/moodle/mod/tresipuntvideo
rm tresipuntvideo.zip
M3IPAUDIO="https://github.com/3iPunt/moodle_mod_tresipuntaudio/archive/refs/heads/master.zip"
if [[ "${MOODLE_PLUGIN_TRESIPUNTAUDIO_OVERRIDE:-${M3IPAUDIO}}" == *"develop"* ]]; then
@ -590,10 +594,10 @@ upgrade_plugins_moodle(){
else
PLUGIN_BRANCH=master
fi
curl --location "${MOODLE_PLUGIN_TRESIPUNTAUDIO_OVERRIDE:-${M3IPAUDIO}}" > tresipuntaudio.zip
unzip tresipuntaudio.zip -d /tmp/moodle/mod/
mv /tmp/moodle/mod/moodle_mod_tresipuntaudio-$PLUGIN_BRANCH /tmp/moodle/mod/tresipuntaudio
rm tresipuntaudio.zip
curl --location "${MOODLE_PLUGIN_TRESIPUNTAUDIO_OVERRIDE:-${M3IPAUDIO}}" > tresipuntaudio.zip
unzip tresipuntaudio.zip -d /tmp/moodle/mod/
mv /tmp/moodle/mod/moodle_mod_tresipuntaudio-$PLUGIN_BRANCH /tmp/moodle/mod/tresipuntaudio
rm tresipuntaudio.zip
M3IPSUBMISSION="https://github.com/3iPunt/moodle_assignsubmission_tipnc/archive/refs/heads/master.zip"
if [[ "${MOODLE_PLUGIN_ASSIGNSUBMISSION_OVERRIDE:-${M3IPSUBMISSION}}" == *"develop"* ]]; then
@ -601,15 +605,15 @@ upgrade_plugins_moodle(){
else
PLUGIN_BRANCH=master
fi
curl --location "${MOODLE_PLUGIN_ASSIGNSUBMISSION_OVERRIDE:-${M3IPSUBMISSION}}" > assignsubmission_tipnc.zip
unzip assignsubmission_tipnc.zip -d /tmp/moodle/mod/assign/submission/
mv /tmp/moodle/mod/assign/submission/moodle_assignsubmission_tipnc-$PLUGIN_BRANCH /tmp/moodle/mod/assign/submission/tipnc
rm assignsubmission_tipnc.zip
curl --location "${MOODLE_PLUGIN_ASSIGNSUBMISSION_OVERRIDE:-${M3IPSUBMISSION}}" > assignsubmission_tipnc.zip
unzip assignsubmission_tipnc.zip -d /tmp/moodle/mod/assign/submission/
mv /tmp/moodle/mod/assign/submission/moodle_assignsubmission_tipnc-$PLUGIN_BRANCH /tmp/moodle/mod/assign/submission/tipnc
rm assignsubmission_tipnc.zip
M3IPSPEND="https://github.com/3iPunt/moodle_block_tresipuntmodspend/archive/refs/heads/master.zip"
curl --location "${MOODLE_PLUGIN_TRESIPUNTMODSPEND_OVERRIDE:-${M3IPSPEND}}" > block_tresipuntmodspend.zip
unzip block_tresipuntmodspend.zip -d /tmp/moodle/blocks/
rm block_tresipuntmodspend.zip
curl --location "${MOODLE_PLUGIN_TRESIPUNTMODSPEND_OVERRIDE:-${M3IPSPEND}}" > block_tresipuntmodspend.zip
unzip block_tresipuntmodspend.zip -d /tmp/moodle/blocks/
rm block_tresipuntmodspend.zip
M3IPCBE="https://github.com/3iPunt/moodle_theme_cbe/archive/refs/heads/master.zip"
if [[ "${MOODLE_THEME_CBE_OVERRIDE:-${M3IPCBE}}" == *"develop"* ]]; then
@ -617,32 +621,32 @@ upgrade_plugins_moodle(){
else
PLUGIN_BRANCH=master
fi
curl --location "${MOODLE_THEME_CBE_OVERRIDE:-${M3IPCBE}}" > tresipunt_theme_cbe.zip
unzip tresipunt_theme_cbe.zip -d /tmp/moodle/theme/cbe/
mv /tmp/moodle/theme/cbe/moodle_theme_cbe-$PLUGIN_BRANCH/* /tmp/moodle/theme/cbe/
rm tresipunt_theme_cbe.zip
curl --location "${MOODLE_THEME_CBE_OVERRIDE:-${M3IPCBE}}" > tresipunt_theme_cbe.zip
unzip tresipunt_theme_cbe.zip -d /tmp/moodle/theme/cbe/
mv /tmp/moodle/theme/cbe/moodle_theme_cbe-$PLUGIN_BRANCH/* /tmp/moodle/theme/cbe/
rm tresipunt_theme_cbe.zip
#mkdir -p /tmp/moodle/local/tresipuntimportgc
#cp -R local_plugins/moodle/tresipuntimportgc/* /tmp/moodle/local/tresipuntimportgc/
#mkdir -p /tmp/moodle/local/tresipuntimportgc
#cp -R local_plugins/moodle/tresipuntimportgc/* /tmp/moodle/local/tresipuntimportgc/
cp -R /tmp/moodle/* $SRC_FOLDER/moodle/
cp -R /tmp/moodle/* "$SRC_FOLDER/moodle/"
rm -rf /tmp/moodle
docker exec -ti dd-apps-moodle php7 admin/cli/purge_caches.php
}
upgrade_plugins_nextcloud(){
wget https://code.jquery.com/jquery-3.2.1.slim.min.js -O $SRC_FOLDER/nextcloud/themes/dd/core/js/jquery_slim_3.2.1.js
cp -R dd-apps/docker/nextcloud/src/* $SRC_FOLDER/nextcloud/
wget https://code.jquery.com/jquery-3.2.1.slim.min.js -O "$SRC_FOLDER/nextcloud/themes/dd/core/js/jquery_slim_3.2.1.js"
cp -R dd-apps/docker/nextcloud/src/* "$SRC_FOLDER/nextcloud/"
nextcloud_upgrade
}
upgrade_plugins_wp(){
cp -R dd-apps/docker/wordpress/src/* $SRC_FOLDER/wordpress/
cp -R dd-apps/docker/wordpress/src/* "$SRC_FOLDER/wordpress/"
if [ ! -d $SRC_FOLDER/wordpress/wp-content/mu-plugins ]; then
git clone https://gitlab.com/muplugins-multiste1/muplugins-google-sites.git $SRC_FOLDER/wordpress/wp-content/mu-plugins
if [ ! -d "$SRC_FOLDER/wordpress/wp-content/mu-plugins" ]; then
git clone https://gitlab.com/muplugins-multiste1/muplugins-google-sites.git "$SRC_FOLDER/wordpress/wp-content/mu-plugins"
fi
if [ ! -d $SRC_FOLDER/wordpress/wp-content/mu-plugins/.git ]; then
if [ ! -d "$SRC_FOLDER/wordpress/wp-content/mu-plugins/.git" ]; then
echo "WARNING: $SRC_FOLDER/wordpress/wp-content/mu-plugins is not a git repository."
echo " This could be due to old installation. To bring all new mu-plugins code for WP"
echo " remove that folder and it will be cloned and mantained with git from now on."
@ -650,16 +654,20 @@ upgrade_plugins_wp(){
sh -c "cd $SRC_FOLDER/wordpress/wp-content/mu-plugins; git pull"
fi
docker-compose run --user=root dd-apps-wordpress-cli /bin/bash -c 'chown -R 33:33 /var/www/html/wp-content/mu-plugins;'
# TODO: Fix this, check https://gitlab.com/DD-workspace/DD/-/issues/16
##install plugin gsite
docker exec dd-apps-wordpress apt-get update
docker exec dd-apps-wordpress apt-get install git -y
docker exec dd-apps-wordpress apt install zlib1g-dev libjpeg-dev libpng-dev -y
docker exec dd-apps-wordpress apt-get install python3 python3-click python3-scrapy python3-unidecode python3-pillow python3-slugify -y
docker exec dd-apps-wordpress git clone https://gitlab.com/isard/gsite2wordpress
docker exec dd-apps-wordpress mv /var/www/html/gsite2wordpress /var/www
docker exec dd-apps-wordpress curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
docker exec dd-apps-wordpress chmod +x wp-cli.phar
docker exec dd-apps-wordpress mv wp-cli.phar /usr/local/bin/wp
docker exec -i dd-apps-wordpress sh -s <<-EOF
apt-get update
apt-get install -y git
apt install -y zlib1g-dev libjpeg-dev libpng-dev
apt-get install -y python3 python3-click python3-scrapy python3-unidecode python3-pillow python3-slugify
apt-get install -y curl
git clone https://gitlab.com/isard/gsite2wordpress
mv /var/www/html/gsite2wordpress /var/www
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
EOF
}
update_logos_and_menu(){
@ -673,9 +681,11 @@ update_logos_and_menu(){
}
configure_nextcloud_logo(){
local instance_id=$(docker exec -u www-data dd-apps-nextcloud-app php occ config:system:get instanceid)
local cachebuster=$(docker exec -u www-data dd-apps-nextcloud-app php occ config:app:get theming cachebuster)
docker exec -u www-data dd-apps-nextcloud-app mkdir -p /var/www/html/data/appdata_$instance_id/theming/images
local instance_id
instance_id=$(docker exec -u www-data dd-apps-nextcloud-app php occ config:system:get instanceid)
local cachebuster
cachebuster=$(docker exec -u www-data dd-apps-nextcloud-app php occ config:app:get theming cachebuster)
docker exec -u www-data dd-apps-nextcloud-app mkdir -p "/var/www/html/data/appdata_$instance_id/theming/images"
nc_logo="${DATA_FOLDER}/nextcloud/appdata_$instance_id/theming/images/logo"
nc_background="${DATA_FOLDER}/nextcloud/appdata_$instance_id/theming/images/background"
cp custom/img/logo.png "${nc_logo}"
@ -683,7 +693,7 @@ configure_nextcloud_logo(){
chown 82:82 "${nc_logo}" "${nc_background}"
docker exec -u www-data dd-apps-nextcloud-app php occ config:app:set theming logoMime --value="image/png"
docker exec -u www-data dd-apps-nextcloud-app php occ config:app:set theming backgroundMime --value="image/png"
docker exec -u www-data dd-apps-nextcloud-app php occ config:app:set theming cachebuster --value="$(expr $cachebuster + 1 )"
docker exec -u www-data dd-apps-nextcloud-app php occ config:app:set theming cachebuster --value="$((cachebuster + 1 ))"
}
genpwd() {