#!/bin/bash # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 source "$(dirname -- "$0")/lib/ulib/auto" || exit 1 function display_help() { uecho "$scriptname: Changer la version de WebObjects pour le système en cours USAGE $scriptname [-f from.files] to-archive.tar.gz OPTIONS -f from.files Spécifier la liste des fichiers pour la version de WebObjects installée. Par défaut, il s'agit de WebObjects-.files La liste doit correspondre à la version en cours. -F Forcer l'installation, même si la version en cours ne correspond pas à ce qui est inscrit dans from.files to-archive.tar.gz Nom de l'archive qui contient la version à installer. Ce script ne fonctionne que sur MacOS X Le contenu des répertoires suivants est sauvegardé avant le changement: /Library/WebObject/Applications /Library/WebObject/Configuration /Library/WebObject/Extensions Ensuite, les répertoires Applications et Configuration sont restaurés. Il faudra restaurer Extensions manuellement." } nocheck= from= to= parse_opts "${PRETTYOPTS[@]}" \ --help '$exit_with display_help' \ -f: from= \ -F nocheck=1 \ @ args -- "$@" && set -- "${args[@]}" || die "$args" check_sysinfos -s macosx || die "Ce script est fait uniquement pour MacOS X" run_as_root -f "$from" ${nocheck:+-F} "$@" version="$(grep -A 1 CFBundleShortVersionString /System/Library/Frameworks/JavaWebObjects.framework/Resources/version.plist | tail -1 | sed 's/^.*\(.*\)<\/string>.*$/\1/')" [ -z "$from" ] && from="WebObjects-$version.files" [ -f "$from" ] || die "$from: Fichier inexistant" if [ -z "$nocheck" ]; then fromversion="$(grep '^# version=' "$from")" fromversion="${fromversion#\# version=}" [ "$version" == "$fromversion" ] || die "$from ne correspond pas à la version installée" fi to="$1" [ -n "$to" ] || die "Il faut spécifier l'archive de la nouvelle version de WebObjects" [ -f "$to" ] || die "$to: Fichier inexistant" etitle "Arrêt de wotaskd et du moniteur" launchctl unload -w /System/Library/LaunchDaemons/com.apple.womonitor.plist launchctl unload -w /System/Library/LaunchDaemons/com.apple.wotaskd.plist eend [ "${version#5.4}" != "$version" ] && from54=1 || from54= toVersion="${to#WebObjects-}"; toVersion="${to%.tar.gz}" [ "${toVersion#5.3}" != "$toVersion" ] && to53=1 || to53= ADAPTOR= if [ -n "$from54" -a -n "$to53" ]; then ac_set_tmpfile ADAPTOR etitle "Copie de l'adaptor pour Apache 2.2" \ tar czf "$ADAPTOR" -C /System/Library/WebObjects/Adaptors Apache2.2 fi ac_set_tmpfile APPCONF etitle "Sauvegarde de /Library/WebObjects/{Applications,Configuration}" \ tar czf "$APPCONF" -C /Library/WebObjects Applications Configuration EXTENSIONS="$HOME/Library-WebObjects-Extensions.tar.gz" etitle "Sauvegarde de /Library/WebObjects/Extensions" \ tar czf "$EXTENSIONS" -C /Library/WebObjects Extensions etitle "Suppression de WebObjects $version" array_from_lines sources "$(grep -v '^#' <"$from")" for source in "${sources[@]}"; do ebegin "$source" rm -rf "$source" & ewait $! eend done eend etitle "Installation de la nouvelle version" \ tar xpzf "$to" -C / if [ -n "$ADAPTOR" ]; then etitle "Restauration de l'adaptor pour Apache 2.2" \ tar xpzf "$ADAPTOR" -C /System/Library/WebObjects/Adaptors fi etitle "Restauration de /Library/WebObjects/{Applications,Configuration}" \ tar xpzf "$APPCONF" -C /Library/WebObjects eimportant "\ Les fichiers de /Library/WebObjects/Extensions se trouvent dans l'archive $(ppath "$EXTENSIONS") Veuillez restaurer les jars utiles aux applications installées." enote "\ Vous pourrez ensuite relancer wotaskd et le moniteur avec les commandes suivantes: # launchctl load -w /System/Library/LaunchDaemons/com.apple.wotaskd.plist && launchctl load -w /System/Library/LaunchDaemons/com.apple.womonitor.plist Attention! ne pas utiliser sudo mais le faire avec le compte root"