[debian-edu-commits] debian-edu/ 08/30: debian/educlient.post*: Append package name to script names. Support distro-specific configurations. Set uidNumber:gidNumber of initial user to 500:500 (not 5000:5000).
Mike Gabriel
sunweaver at debian.org
Fri Oct 9 03:44:03 UTC 2015
This is an automated email from the git hooks/post-receive script.
sunweaver pushed a commit to branch multi-distro-support
in repository educlient.
commit ab52118aaef65901543a9602a6012299cdce8a15
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Tue Aug 25 15:24:26 2015 +0200
debian/educlient.post*: Append package name to script names. Support distro-specific configurations. Set uidNumber:gidNumber of initial user to 500:500 (not 5000:5000).
---
debian/educlient.postinst | 130 ++++++++++++++++++++++++++++++++++++++++++++++
debian/educlient.prerm | 57 ++++++++++++++++++++
debian/postinst | 76 ---------------------------
debian/prerm | 29 -----------
4 files changed, 187 insertions(+), 105 deletions(-)
diff --git a/debian/educlient.postinst b/debian/educlient.postinst
new file mode 100755
index 0000000..0454bc0
--- /dev/null
+++ b/debian/educlient.postinst
@@ -0,0 +1,130 @@
+#!/bin/sh
+
+#
+# Post install script for the educlient package
+#
+
+# Source debconf library.
+
+set -xe
+
+# continue if configure used otherwise exit cleanly or abort
+case "$1" in
+ configure)
+ ;;
+ abort-upgrade|abort-remove|abort-deconfigure)
+ exit 0
+ ;;
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+if [ -f /etc/os-release ]; then
+ . /etc/os-release
+fi
+
+if [ -f /etc/lsb-release ]; then
+ . /etc/lsb-release
+fi
+
+# vanilla Debian does not ship /etc/lsb-release...
+if [ "$NAME" = "Debian GNU/Linux" ]; then
+ DISTRIB_ID=Debian
+ DISTRIB_RELEASE=$VERSION_ID
+fi
+
+# Divert configuration files
+ETC_DISTRIB_VERSION="/usr/share/educlient/etc-distrib/${DISTRIB_ID}/${DISTRIB_RELEASE}"
+ETC_DISTRIB_COMMON="/usr/share/educlient/etc-distrib/${DISTRIB_ID}/common"
+ETC_COMMON="/usr/share/educlient/etc-common"
+
+mkdir -p /etc/debian-edu
+echo "" > /etc/debian-edu/educlient.modified-files
+
+for working_dir in ${ETC_DISTRIB_VERSION} ${ETC_DISTRIB_COMMON} ${ETC_COMMON}; do
+
+ if [ ! -d ${working_dir} ]; then
+ continue
+ fi
+ cd ${working_dir}
+ NEEDED_DIRECTORIES=$(find . -type d | cut -c 3-)
+ for i in $NEEDED_DIRECTORIES
+ do
+ if [ ! -d "/$i" ]; then
+ mkdir -p /$i
+ echo "Directory: mkdir -p /$i"
+ fi
+ done
+
+ COPY_DIVERT_FILES=$(find . -type f | cut -c 3-)
+ for i in $COPY_DIVERT_FILES
+ do
+ if [ -e "/$i" ]; then
+
+ # remove previously made diversions
+ if [ "$(dpkg-divert --listpackage /$i)" = "educlient" ] && [ -h /$i ]; then
+ dpkg-divert --package educlient --rename --remove /$i
+ fi
+
+ dpkg-divert --package educlient --add --divert /$i.educlient-orig --rename /$i
+ echo "dpkg-divert --package educlient --add --divert /$i.educlient-orig --rename /$i"
+ ln -s ${working_dir}/$i /$i
+ echo "ln -s ${working_dir}/$i /$i"
+ echo $i >> /etc/debian-edu/educlient.files-diverted
+
+ else
+
+ cp ${working_dir}/$i /$i
+ echo "cp ${working_dir}/$i /$i"
+ echo $i >> /etc/debian-edu/educlient.files-added
+
+ fi
+ done
+
+# Create /skole mount point
+if [ ! -d "/skole" ]; then
+ mkdir /skole
+fi
+
+# Remove ldap.secret
+if [ -e "/etc/ldap.secret" ]; then
+ rm -t /etc/ldap.secret
+fi
+
+# Fetch the ldap cert immediately to avoid double reboot and put SysV and Upstart in order
+if [ -e /sbin/start ]; then
+
+ echo "Upstart detected, starting fetch-ldap-cert with Upstart system"
+
+ start fetch-ldap-cert 2>&1
+
+else
+ echo "SysV/Systemd detected, starting /etc/init.d/fetch-ldap-cert"
+
+ invoke-rc.d fetch-ldap-cert start 2>&1
+fi
+
+# Fix for the mode of autofs5_ldap.conf
+if [ -h /etc/autofs_ldap_auth.conf ]; then
+ chmod 0600 /etc/autofs_ldap_auth.conf
+fi
+
+
+# Move UID and GID of the first local user to 500
+USERN="$(getent passwd 1000 | cut -d ":" -f 1)"
+HOME="$(getent passwd 1000 | cut -d ":" -f 6)"
+sed -i "s/:x:1000:1000:/:x:500:500/g" /etc/passwd
+sed -i "s/:x:1000/:x:500/g" /etc/group
+if which nscd 1>/dev/null; then
+ nscd -i passwd
+ nscd -i group
+fi
+chown -R $USERN:$USERN "$HOME"
+
+echo "You really need to reboot NOW !!!"
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/educlient.prerm b/debian/educlient.prerm
new file mode 100755
index 0000000..16a6076
--- /dev/null
+++ b/debian/educlient.prerm
@@ -0,0 +1,57 @@
+#! /bin/sh
+#
+# pre-removal script for the educlient package
+#
+
+# Divert back all the stuff
+
+if [ -f /etc/os-release ]; then
+ . /etc/os-release
+fi
+
+if [ -f /etc/lsb-release ]; then
+ . /etc/lsb-release
+fi
+
+# vanilla Debian does not ship /etc/lsb-release...
+if [ "$NAME" = "Debian GNU/Linux" ]; then
+ DISTRIB_ID=Debian
+ DISTRIB_RELEASE=$VERSION_ID
+fi
+
+# Divert configuration files
+ETC_DISTRIB_VERSION="/usr/share/educlient/etc-distrib/${DISTRIB_ID}/${DISTRIB_RELEASE}"
+ETC_DISTRIB_COMMON="/usr/share/educlient/etc-distrib/${DISTRIB_ID}/common"
+ETC_COMMON="/usr/share/educlient/etc-common"
+
+if [ ! -f /etc/debian-edu/educlient.files-diverted ] && [ ! -f /etc/debian-edu/educlient.files-added ]; then
+ exit 0
+fi
+
+cat /etc/debian-edu/educlient.files-* | while read file;
+ do
+ if [ "$(dpkg-divert --listpackage /$i)" = "educlient" ]; then
+ if [ -h "/$i" ]; then
+ rm -f /$i
+ fi
+ dpkg-divert --package educlient --rename --remove /$i
+ else
+ mv /$i /$i.educlient-removed
+ fi
+ done
+done
+
+# Revert first user to UID and GID 1000
+USERN=$(getent passwd 500 | cut -d ":" -f 1)
+HOME=$(getent passwd 500 | cut -d ":" -f 6)
+sed "s/:x:500:500:/:x:1000:1000:/g" /etc/passwd
+sed "s/:x:500:/:x:1000:/g" /etc/group
+if which nscd 1>/dev/null; then
+ nscd -i passwd
+ nscd -i group
+fi
+chown -R $USERN:$USERN "$HOME"
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/postinst b/debian/postinst
deleted file mode 100755
index 40c7301..0000000
--- a/debian/postinst
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-#
-# Post install script for the Debian autoclient script
-
-# Source debconf library.
-
-#Divert configuration files
-cd /usr/share/educlient
-
-NEEDED_DIRECTORIES=$(find . -type d | cut -c 3-)
-for i in $NEEDED_DIRECTORIES
- do
- if [ ! -d "/$i" ]; then
- mkdir -p /$i
- echo "Directory: mkdir -p /$i"
- fi
- done
-
-COPY_DIVERT_FILES=$(find . -type f | cut -c 3-)
-for i in $COPY_DIVERT_FILES
- do
- if [ -e "/$i" ]; then
- dpkg-divert --package educlient --add --divert /$i.orig --rename /$i
- echo "dpkg-divert --package educlient --add --divert /$i.orig --rename /$i"
- ln -s /usr/share/educlient/$i /$i
- echo "ln -s /usr/share/educlient/$i /$i"
- else
- cp /usr/share/educlient/$i /$i
- echo "cp /usr/share/educlient/$i /$i"
- fi
- done
-
-#Create /skole mount point
-if [ ! -d "/skole" ]; then
- mkdir /skole
-fi
-
-#Remove ldap.secret
-
-if [ -e "/etc/ldap.secret" ]; then
- rm -t /etc/ldap.secret
-fi
-
-#Fetch the ldap cert immediately to avoid double reboot and put SysV and Upstart in order
-if [ -e /sbin/start ]; then
-
- echo "Upstart detected, starting fetch-ldap-cert with Upstart system"
-
- start fetch-ldap-cert 2>&1
-
-else
- echo "SysV detected, starting /etc/init.d/fetch-ldap-cert"
-
- /etc/init.d/fetch-ldap-cert start 2>&1
-
- /sbin/insserv /etc/init.d/fetch-ldap-cert 2>&1
-
-fi
-
-#Fix for the mode of autofs5_ldap.conf
-if [ -h /etc/autofs_ldap_auth.conf ]; then
- chmod 0600 /etc/autofs_ldap_auth.conf
-fi
-
-
-#Move UID and GID of the first local user to 10000
-USERN=`getent passwd 1000 | cut -d ":" -f 1`
-sed -i "s/1000/5000/g" /etc/passwd
-sed -i "s/1000/5000/g" /etc/group
-chown -R $USERN:$USERN /home/$USERN
-
-echo "You really need to reboot NOW !!!"
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/prerm b/debian/prerm
deleted file mode 100755
index fd2fbff..0000000
--- a/debian/prerm
+++ /dev/null
@@ -1,29 +0,0 @@
-#! /bin/sh
-#
-# Pre removal script for the Debian autoclient script
-#
-
-#Divert back all the stuff
-
-cd /usr/share/educlient
-
-COPY_DIVERT_FILES=$(find . -type f | cut -c 3-)
-for i in $COPY_DIVERT_FILES
- do
- if [ -h "/$i" ]; then
- rm -f /$i
- dpkg-divert --package educlient --rename --remove /$i
- else
- rm -f /$i
- fi
- done
-
-#Revert first user to UID and GID 1000
-USERN=`getent passwd 5000 | cut -d ":" -f 1`
-sed "s/5000/1000/g" /etc/passwd
-sed "s/5000/1000/g" /etc/group
-chown -R $USERN:$USERN /home/$USERN
-
-#DEBHELPER#
-
-exit 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/educlient.git
More information about the debian-edu-commits
mailing list