[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
# 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
}
@ -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
@ -625,24 +629,24 @@ upgrade_plugins_moodle(){
#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() {