diff --git a/debian/postinst b/debian/postinst index 279301c20..564c9e1eb 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,56 +1,85 @@ #!/bin/bash +#!/bin/sh +# postinst script for yunohost-config-metronome -TMP=/usr/share/yunohost/yunohost-config/moulinette +set -e -if [ ! -d /etc/yunohost ]; -then - mkdir -p /etc/yunohost -fi +do_configure() { + TMP=/usr/share/yunohost/yunohost-config/moulinette -# Allow users to access /media directory -if [ ! -d /etc/skel/media ]; -then - mkdir -p /media - ln -s /media /etc/skel/ -fi + if [ ! -d /etc/yunohost ]; + then + mkdir -p /etc/yunohost + fi -#Firewall -grep -q "UPNP:" /etc/yunohost/firewall.yml > /dev/null 2>&1 -if [[ $? -eq 0 ]] || [ ! -f /etc/yunohost/firewall.yml ]; -then - cp $TMP/firewall.yml /etc/yunohost/ -fi + # Allow users to access /media directory + if [ ! -d /etc/skel/media ]; + then + mkdir -p /media + ln -s /media /etc/skel/ + fi -# App fetchlist -if [ -f /etc/cron.d/yunohost-applist-yunohost ]; -then - sed -i "s/--no-ldap //g" /etc/cron.d/yunohost-applist-yunohost -fi + #Firewall + grep -q "UPNP:" /etc/yunohost/firewall.yml > /dev/null 2>&1 + if [[ $? -eq 0 ]] || [ ! -f /etc/yunohost/firewall.yml ]; + then + cp $TMP/firewall.yml /etc/yunohost/ + fi -# Service list -if [ ! -f /etc/yunohost/services.yml ]; -then - cp $TMP/services.yml /etc/yunohost/ -fi + # App fetchlist + if [ -f /etc/cron.d/yunohost-applist-yunohost ]; + then + sed -i "s/--no-ldap //g" /etc/cron.d/yunohost-applist-yunohost + fi -# Stop old API -ps aux | grep "yunohost.tac" | grep -qv grep -if [[ $? -eq 0 ]]; -then - killall twistd -fi + # Service list + if [ ! -f /etc/yunohost/services.yml ]; + then + cp $TMP/services.yml /etc/yunohost/ + fi -rm -rf /var/cache/moulinette/* -update-rc.d yunohost-api defaults -service yunohost-api restart + # Stop old API + ps aux | grep "yunohost.tac" | grep -qv grep + if [[ $? -eq 0 ]]; + then + killall twistd + fi -# Reload SSOwat conf if obsolete -if [ -f /etc/yunohost/installed ]; -then - yunohost firewall upnp | grep -qi "true" - if [[ $? -eq 0 ]]; - then - yunohost firewall upnp enable - fi - yunohost app ssowatconf -fi + rm -rf /var/cache/moulinette/* + update-rc.d yunohost-api defaults + service yunohost-api restart + + # Reload SSOwat conf if obsolete + if [ -f /etc/yunohost/installed ]; + then + yunohost firewall upnp | grep -qi "true" + if [[ $? -eq 0 ]]; + then + yunohost firewall upnp enable + fi + yunohost app ssowatconf + fi +} + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +case "$1" in + configure) + do_configure + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac