[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

62
dd-ctl
View File

@ -225,6 +225,7 @@ listpatches(){
# Generate .orig and .patch files with ./dd-ctl genpatches # Generate .orig and .patch files with ./dd-ctl genpatches
# file license author url # file license author url
EOM EOM
# shellcheck disable=SC2044 # TODO: Get rid of this for X in find
for patchfile in $(find . -name 'dd-patch'); do for patchfile in $(find . -name 'dd-patch'); do
patchdir="$(dirname "${patchfile}")" patchdir="$(dirname "${patchfile}")"
grep -vE '^#' "${patchfile}" | awk "{print \"${patchdir}/\" \$0}" grep -vE '^#' "${patchfile}" | awk "{print \"${patchdir}/\" \$0}"
@ -233,7 +234,9 @@ listpatches(){
genpatches(){ genpatches(){
CD="$(pwd)" CD="$(pwd)"
# shellcheck disable=SC2044 # TODO: Get rid of this for X in find
for patchfile in $(find . -name 'dd-patch'); do for patchfile in $(find . -name 'dd-patch'); do
# shellcheck disable=SC2164 # We got the dir from find
cd "$(dirname "${patchfile}")" cd "$(dirname "${patchfile}")"
echo "IN DIR $(pwd)" echo "IN DIR $(pwd)"
grep -vE '^#' dd-patch | while IFS= read -r line; do grep -vE '^#' dd-patch | while IFS= read -r line; do
@ -242,7 +245,7 @@ genpatches(){
wget "${url}" -O "${fn}.orig" wget "${url}" -O "${fn}.orig"
diff "${fn}.orig" "${fn}" > "${fn}.patch" diff "${fn}.orig" "${fn}" > "${fn}.patch"
done done
# shellcheck disable=SC2164 # This was previous working dir
cd "${CD}" cd "${CD}"
done done
} }
@ -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 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 # Add default file for moodle activities
if [ ! -f $DATA_FOLDER/nextcloud/admin/files/template.docx ]; then if [ ! -f "$DATA_FOLDER/nextcloud/admin/files/template.docx" ]; then
cp dd-apps/docker/nextcloud/template.docx $DATA_FOLDER/nextcloud/admin/files/ cp dd-apps/docker/nextcloud/template.docx "$DATA_FOLDER/nextcloud/admin/files/"
nextcloud_scan nextcloud_scan
fi fi
@ -494,7 +497,7 @@ saml_certificates(){
wait_for_moodle(){ wait_for_moodle(){
echo "Waiting for system to be fully up before customizing... It can take some minutes..." 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" 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(){ upgrade_moodle(){
@ -532,9 +535,10 @@ extras_nextcloud_set_admin_group(){
} }
extras_dump_keycloak_client(){ 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 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(){ upgrade_plugins_moodle(){
wait_for_moodle wait_for_moodle
@ -625,24 +629,24 @@ upgrade_plugins_moodle(){
#mkdir -p /tmp/moodle/local/tresipuntimportgc #mkdir -p /tmp/moodle/local/tresipuntimportgc
#cp -R local_plugins/moodle/tresipuntimportgc/* /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 rm -rf /tmp/moodle
docker exec -ti dd-apps-moodle php7 admin/cli/purge_caches.php docker exec -ti dd-apps-moodle php7 admin/cli/purge_caches.php
} }
upgrade_plugins_nextcloud(){ 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 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/ cp -R dd-apps/docker/nextcloud/src/* "$SRC_FOLDER/nextcloud/"
nextcloud_upgrade nextcloud_upgrade
} }
upgrade_plugins_wp(){ 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 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 git clone https://gitlab.com/muplugins-multiste1/muplugins-google-sites.git "$SRC_FOLDER/wordpress/wp-content/mu-plugins"
fi 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 "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 " 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." 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" sh -c "cd $SRC_FOLDER/wordpress/wp-content/mu-plugins; git pull"
fi fi
docker-compose run --user=root dd-apps-wordpress-cli /bin/bash -c 'chown -R 33:33 /var/www/html/wp-content/mu-plugins;' 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 ##install plugin gsite
docker exec dd-apps-wordpress apt-get update docker exec -i dd-apps-wordpress sh -s <<-EOF
docker exec dd-apps-wordpress apt-get install git -y apt-get update
docker exec dd-apps-wordpress apt install zlib1g-dev libjpeg-dev libpng-dev -y apt-get install -y git
docker exec dd-apps-wordpress apt-get install python3 python3-click python3-scrapy python3-unidecode python3-pillow python3-slugify -y apt install -y zlib1g-dev libjpeg-dev libpng-dev
docker exec dd-apps-wordpress git clone https://gitlab.com/isard/gsite2wordpress apt-get install -y python3 python3-click python3-scrapy python3-unidecode python3-pillow python3-slugify
docker exec dd-apps-wordpress mv /var/www/html/gsite2wordpress /var/www apt-get install -y curl
docker exec dd-apps-wordpress curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar git clone https://gitlab.com/isard/gsite2wordpress
docker exec dd-apps-wordpress chmod +x wp-cli.phar mv /var/www/html/gsite2wordpress /var/www
docker exec dd-apps-wordpress mv wp-cli.phar /usr/local/bin/wp 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(){ update_logos_and_menu(){
@ -673,9 +681,11 @@ update_logos_and_menu(){
} }
configure_nextcloud_logo(){ configure_nextcloud_logo(){
local instance_id=$(docker exec -u www-data dd-apps-nextcloud-app php occ config:system:get instanceid) local instance_id
local cachebuster=$(docker exec -u www-data dd-apps-nextcloud-app php occ config:app:get theming cachebuster) instance_id=$(docker exec -u www-data dd-apps-nextcloud-app php occ config:system:get instanceid)
docker exec -u www-data dd-apps-nextcloud-app mkdir -p /var/www/html/data/appdata_$instance_id/theming/images 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_logo="${DATA_FOLDER}/nextcloud/appdata_$instance_id/theming/images/logo"
nc_background="${DATA_FOLDER}/nextcloud/appdata_$instance_id/theming/images/background" nc_background="${DATA_FOLDER}/nextcloud/appdata_$instance_id/theming/images/background"
cp custom/img/logo.png "${nc_logo}" cp custom/img/logo.png "${nc_logo}"
@ -683,7 +693,7 @@ configure_nextcloud_logo(){
chown 82:82 "${nc_logo}" "${nc_background}" 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 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 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() { genpwd() {