2013-08-27 15:14:44 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
|
|
|
|
source "$1" || exit 1 # pour avoir la définition de ULIBDIR
|
2014-07-07 22:06:38 +04:00
|
|
|
source "$ULIBDIR/ulib" || exit 1
|
|
|
|
urequire DEFAULTS prefixes apache webobjects wosign
|
2013-08-27 15:14:44 +04:00
|
|
|
|
|
|
|
is_root || die "Ce script doit être lancé avec les droits de root"
|
|
|
|
|
|
|
|
set_defaults WOServices
|
|
|
|
urequire wondermonitor
|
|
|
|
|
|
|
|
compute_apache_prefixes
|
|
|
|
compute_webobjects_prefixes
|
|
|
|
source "$1" # relire les éventuelles valeurs forcées pour les préfixes
|
|
|
|
|
|
|
|
create_wodirs_maybe
|
|
|
|
wosign_setup_maybe
|
|
|
|
|
|
|
|
function rm_ifexists() {
|
|
|
|
if [ -d "$1" ]; then
|
|
|
|
/bin/rm -rf "$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
# récupérer les informations sur le mapping bundle -> application
|
|
|
|
wom_getApplications appinfos
|
|
|
|
|
|
|
|
# Calculer les instances à relancer, en fonctions des applications et des
|
|
|
|
# frameworks à déployer
|
|
|
|
apps_to_restart=("${applications[@]}" "${frameworks[@]}")
|
|
|
|
array_map apps_to_restart basename
|
|
|
|
etitle "Calcul des instances à relancer" \
|
|
|
|
compute_apps apps_to_restart appinfos "${apps_to_restart[@]}"
|
|
|
|
|
|
|
|
if [ -z "$bounce" ]; then
|
|
|
|
# Arrêter les instances
|
|
|
|
disable_autorecover=1
|
|
|
|
stop_apps -a apps_to_start "" "" "${apps_to_restart[@]}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Déployer les frameworks
|
|
|
|
|
|
|
|
if [ -n "${frameworks[*]}" ]; then
|
|
|
|
etitle -s "Déploiement des frameworks"
|
|
|
|
destdir="$WOFRAMEWORKS"
|
|
|
|
webdestdir="$HTDOCSDIR/WebObjects/Frameworks"
|
|
|
|
|
|
|
|
for bundle in "${frameworks[@]}"; do
|
|
|
|
fwkname="$(basename "$bundle")"
|
|
|
|
fwkbasename="${fwkname%.framework}"
|
|
|
|
fwkdesc=
|
|
|
|
oldfwkname="$fwkname.orig"
|
|
|
|
|
|
|
|
etitle -s "$fwkname${fwkdesc:+: $fwkdesc}"
|
|
|
|
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
ebegin "Correction de la casse du jar principal"
|
|
|
|
jar="$(awk <"$bundle/Resources/Info.plist" '
|
|
|
|
/<key>NSJavaPathClient<\/key>/ {
|
|
|
|
getline
|
|
|
|
gsub("^.*<string>", "")
|
|
|
|
gsub("</string>.*$", "")
|
|
|
|
print
|
|
|
|
}
|
|
|
|
')"
|
|
|
|
if [ -n "$jar" ]; then
|
|
|
|
lower_jar="$bundle/Resources/Java/$(echo "$jar" | awk '{print tolower($0)}')"
|
|
|
|
jar="$bundle/Resources/Java/$jar"
|
|
|
|
if [ ! -f "$jar" -a -f "$lower_jar" ]; then
|
|
|
|
/bin/mv "$lower_jar" "$jar"; edot
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
eend
|
|
|
|
fi
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
if reason="$(wosignable "$bundle")"; then
|
|
|
|
estep "Signature des jars"
|
|
|
|
wosign -d -s "$bundle"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$destdir/$fwkname" ]; then
|
|
|
|
ebegin "Suppression de l'ancienne installation"
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
rm_ifexists "$destdir/$oldfwkname"; edot
|
|
|
|
/bin/mv "$destdir/$fwkname" "$destdir/$oldfwkname"; edot
|
|
|
|
fi
|
|
|
|
rm_ifexists "$webdestdir/$oldfwkname"; edot
|
|
|
|
if [ -d "$webdestdir/$fwkname" ]; then
|
|
|
|
/bin/mv "$webdestdir/$fwkname" "$webdestdir/$oldfwkname"; edot
|
|
|
|
fi
|
|
|
|
eend
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
# copie des fichiers
|
|
|
|
ebegin "Copie des fichiers"
|
|
|
|
mkdir -p "$destdir"; edot
|
|
|
|
cpdir "$bundle" "$destdir/$fwkname" &
|
|
|
|
ewait $!
|
|
|
|
eend
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
# permissions
|
|
|
|
ebegin "Ajustement des permission"
|
|
|
|
chown -R root: "$destdir/$fwkname"; edot
|
|
|
|
chmod -R u=rwX,g=rX,o=rX "$destdir/$fwkname"; edot
|
|
|
|
eend
|
|
|
|
fi
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
if [ -d "$bundle/WebServerResources" ]; then
|
|
|
|
# copie des fichiers pour le web
|
|
|
|
ebegin "Copie des ressources web"
|
|
|
|
cpdir "$bundle/WebServerResources" "$webdestdir/$fwkname/WebServerResources" &
|
|
|
|
ewait $!
|
|
|
|
eend
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
# permissions
|
|
|
|
ebegin "Ajustement des permission"
|
|
|
|
chown -R root: "$webdestdir/$fwkname"; edot
|
|
|
|
chmod -R u=rwX,g=rX,o=rX "$webdestdir/$fwkname"; edot
|
|
|
|
eend
|
|
|
|
fi
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
eend
|
|
|
|
done
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
eend
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Déployer les applications
|
|
|
|
|
|
|
|
if [ -n "${applications[*]}" ]; then
|
|
|
|
etitle -s "Déploiement des applications"
|
|
|
|
destdir="$WOAPPLICATIONS"
|
|
|
|
webdestdir="$HTDOCSDIR/WebObjects"
|
|
|
|
|
|
|
|
for bundle in "${applications[@]}"; do
|
|
|
|
appname="$(basename "$bundle")"
|
|
|
|
appbasename="${appname%.woa}"
|
|
|
|
appdesc=
|
|
|
|
oldappname="$appname.orig"
|
|
|
|
|
|
|
|
etitle -s "$appname${appdesc:+: $appdesc}"
|
|
|
|
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
estep "Correction éventuelle de la casse des jars"
|
|
|
|
fix_jars_case "$bundle"
|
|
|
|
fi
|
|
|
|
|
|
|
|
estep "Vérification du bundle"
|
|
|
|
verifix_bundle "$bundle"
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
if reason="$(wosignable "$bundle")"; then
|
|
|
|
estep "Signature des jars"
|
|
|
|
wosign -d -s "$bundle"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$destdir/$appname" ]; then
|
|
|
|
ebegin "Suppression de l'ancienne installation"
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
rm_ifexists "$destdir/$oldappname"; edot
|
|
|
|
/bin/mv "$destdir/$appname" "$destdir/$oldappname"; edot
|
|
|
|
fi
|
|
|
|
rm_ifexists "$webdestdir/$oldappname"; edot
|
|
|
|
if [ -d "$webdestdir/$appname" ]; then
|
|
|
|
/bin/mv "$webdestdir/$appname" "$webdestdir/$oldappname"; edot
|
|
|
|
fi
|
|
|
|
eend
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
# copie des fichiers
|
|
|
|
ebegin "Copie des fichiers"
|
|
|
|
mkdir -p "$destdir"; edot
|
|
|
|
cpdir "$bundle" "$destdir/$appname" &
|
|
|
|
ewait $!
|
|
|
|
eend
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
# permissions
|
|
|
|
ebegin "Ajustement des permission"
|
|
|
|
chown -R root: "$destdir/$appname"; edot
|
|
|
|
chmod -R u=rwX,g=rX,o=rX "$destdir/$appname"; edot
|
|
|
|
eend
|
|
|
|
fi
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
if [ -d "$bundle/Contents/WebServerResources" ]; then
|
|
|
|
# copie des fichiers pour le web
|
|
|
|
ebegin "Copie des ressources web"
|
|
|
|
cpdir "$bundle/Contents/WebServerResources" "$webdestdir/$appname/Contents/WebServerResources" &
|
|
|
|
ewait $!
|
2016-06-22 15:43:26 +04:00
|
|
|
if [ -d "$bundle/Contents/Frameworks" ]; then
|
|
|
|
cpdir "$bundle/Contents/Frameworks" "$webdestdir/$appname/Contents/Frameworks" &
|
|
|
|
ewait $!
|
|
|
|
fi
|
2013-08-27 15:14:44 +04:00
|
|
|
eend
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
# permissions
|
|
|
|
ebegin "Ajustement des permission"
|
|
|
|
chown -R root: "$webdestdir/$appname"; edot
|
|
|
|
chmod -R u=rwX,g=rX,o=rX "$webdestdir/$appname"; edot
|
|
|
|
eend
|
|
|
|
fi
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
eend
|
|
|
|
done
|
2015-08-20 07:58:17 +04:00
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
eend
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
if [ -z "$webinst" ]; then
|
|
|
|
if [ -z "$bounce" ]; then
|
|
|
|
# Démarrer les instances
|
|
|
|
enable_autorecover=1
|
|
|
|
start_apps "" "" "${apps_to_start[@]}"
|
|
|
|
else
|
|
|
|
# Relancer les applications en mode bounce
|
|
|
|
bounce_apps "" "" "${apps_to_restart[@]}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Lancer les scripts
|
|
|
|
|
|
|
|
for script in "${scripts[@]}"; do
|
|
|
|
eval "$script"
|
|
|
|
done
|