Current Path : /var/lib/dpkg/info/ |
Current File : /var/lib/dpkg/info/coremanager.preinst |
#!/bin/bash # preinst script for coremanager # # see: dh_installdeb(1) #set -e # summary of how this script can be called: # * <new-preinst> `install' # * <new-preinst> `install' <old-version> # * <new-preinst> `upgrade' <old-version> # * <old-preinst> `abort-upgrade' <new-version> # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package COREDIR=/usr/local/mgr5 MGR=core # Clean old external libs if [ -d ${COREDIR}/external ]; then find ${COREDIR}/external -type f | grep -v gtest | awk '{print "dpkg -S " $1 " >/dev/null 2>&1 || rm " $1}' | sh find ${COREDIR}/external -type l | grep -v gtest | awk '{print "dpkg -S " $1 " >/dev/null 2>&1 || rm " $1}' | sh fi case "$1" in install) test "#${ISPCONVERT}" = "#yes" && exit 0 Error() { echo -e "\033[1;31m$@\033[0m" } test -f /.dockerinit && exit 0 test "#${IGNORE_HOSTNAME}" = "#yes" && exit 0 ## Checking /usr/local/ispmgr if [ "${MIGRATION}" != "mgr5" ] && [ -d /usr/local/ispmgr ]; then Error "=================================================" Error "Directory /usr/local/ispmgr exist!" Error "Working with old version is unsupported!" Error "=================================================" exit 1 fi # Ignoring hostname exit 0 ## Checking hostname HOSTNAME=$(hostname -f) bad_hostname_msg() { Error "=================================================" Error "You have invalid hostname: \"${HOSTNAME}\"" Error "Please change your hostname to correct." Error "See http://en.wikipedia.org/wiki/Hostname" Error "=================================================" exit 1 } LENGTH=0 LENGTH=$(echo ${HOSTNAME} | wc -m) if [ ${LENGTH} -lt 2 -o ${LENGTH} -gt 50 ]; then bad_hostname_msg fi if ! echo ${HOSTNAME} | grep -q '\.'; then bad_hostname_msg fi if echo ${HOSTNAME} | grep -q '_'; then bad_hostname_msg fi TOPLEVEL=$(echo ${HOSTNAME} | awk -F. '{print $NF}') if [ -z "${TOPLEVEL}" ]; then bad_hostname_msg fi if [ -n "$(echo ${TOPLEVEL} | sed -r 's/[a-zA-Z0-9\-]//g')" ]; then bad_hostname_msg fi ;; upgrade) if [ ! -f /etc/apt/sources.list.d/ispsystem-base.list ]; then cat /etc/apt/sources.list.d/ispsystem.list | sed -r 's|intrepo\.||g; s|(\s)\w+-|\1base-|' > /etc/apt/sources.list.d/ispsystem-base.list fi mkdir -p ${COREDIR}/tmp ${COREDIR}/sbin/mgrctl -l || : ;; abort-upgrade) ;; *) echo "preinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. exit 0