[osiris-devel] osiris 4.0 beta install script patch

osiris-devel at lemmin.gs osiris-devel at lemmin.gs
Sun Apr 4 08:16:32 EDT 2004


Hello,

Patch attached to make the installer script more friendly
for packagers.

emmanuel
-------------- next part --------------
--- osiris-4.0.0-beta/src/install/install.sh.in.orig	2004-03-31 04:18:26.000000000 +1000
+++ osiris-4.0.0-beta/src/install/install.sh.in	2004-04-04 18:47:53.000000000 +1000
@@ -26,8 +26,11 @@
 
 USER_EXISTS=0
 INSTALL_OSIRISM=0
+INTERACTIVE=1
+PACKAGE_MODE=0
 
-INSTALL_DIR="@prefix@/sbin"
+SBIN_DIR="@prefix@/sbin"
+INSTALL_DIR="${DESTDIR}${SBIN_DIR}"
 OSIRIS_DIR="@with_root_dir@"
 
 # ---------------------------------------------------------------------------
@@ -36,6 +39,11 @@
 
 create_user_and_group()
 {
+    if [ ${PACKAGE_MODE} -eq 1 ]; then
+        echo "==> Skipping user/group creation."
+        return
+    fi
+
     case `uname -s`  in
 
 Linux|OpenBSD)
@@ -211,6 +219,11 @@
 
 set_permissions()
 {
+    if [ ${PACKAGE_MODE} -eq 1 ]; then
+		echo "==> Skipping permission setting."
+		return
+    fi
+
     if [ `uname -s` = 'SunOS' ]; then
         ${CHOWN} ${USER}  ${OSIRIS_DIR}
         ${CHGRP} ${GROUP} ${OSIRIS_DIR}
@@ -271,7 +284,7 @@
     Linux*) 
     if [ "${DISTRO}" = "" ]; then
         if [ -e /proc/version ]; then
-         DISTRO=`cat /proc/version | grep -oi -e 'SuSE' -e 'Red Hat' -e 'Redhat' -e 'Debian'`
+         DISTRO=`cat /proc/version | grep -oi -e 'SuSE' -e 'Red Hat' -e 'Redhat' -e 'Debian' | tr A-Z a-z`
 
          if [ "${DISTRO}" = "red hat" ]; then
              DISTRO="redhat"
@@ -368,6 +381,7 @@
     # CLI management app.
 
     if [ $INSTALL_OSIRISM != 0 -a -f ./osiris ]; then
+	${MKDIR} -p ${INSTALL_DIR}
         ${CP} ./osiris ${INSTALL_DIR}
         echo "==> installed osiris CLI: ${INSTALL_DIR}/osiris"
     fi
@@ -375,6 +389,7 @@
     # scanning agent.
 
     if [ -f ./osirisd ]; then
+	${MKDIR} -p ${INSTALL_DIR}
         ${CP} ./osirisd ${INSTALL_DIR}
         echo "==> installed scan agent: ${INSTALL_DIR}/osirisd"
     fi
@@ -382,6 +397,7 @@
     # management console.
 
     if [ $INSTALL_OSIRISM != 0 -a -f ./osirismd ]; then
+	${MKDIR} -p ${INSTALL_DIR}
         ${CP} ./osirismd ${INSTALL_DIR}
         echo "==> installed management console ${INSTALL_DIR}/osirismd"
 
@@ -390,8 +406,8 @@
     # and then copy over the default configs.
 
     if [ -d ./configs ]; then
-        ${MKDIR} -p ${OSIRIS_DIR}/configs
-        ${CP} -rf ./configs/default.* ${OSIRIS_DIR}/configs
+        ${MKDIR} -p ${DESTDIR}${OSIRIS_DIR}/configs
+        ${CP} -rf ./configs/default.* ${DESTDIR}${OSIRIS_DIR}/configs
         echo "==> installed default scan configs."
     fi
 
@@ -463,6 +479,11 @@
 
 post_install()
 {
+    if [ ${PACKAGE_MODE} -eq 1 ]; then
+		echo "==> Skipping post install."
+		return
+    fi
+
 # now give some instructions on how to start daemons for those that need it.
 
 echo ""
@@ -476,8 +497,7 @@
 
     default="y"
     prompt="Start management console now? (y/n) [${default}] "
-    printf "%s" "$prompt "
-    read answer
+	ask "$prompt"
 
     if [ -z "${answer}" ] ; then
         answer=$default
@@ -495,8 +515,7 @@
 
 default="y"
 prompt="Start scan agent now? (y/n) [${default}] "
-printf "%s" "$prompt "
-read answer
+ask "$prompt"
 
     if [ -z "${answer}" ] ; then
         answer=$default
@@ -523,6 +542,22 @@
 }
 
 # ---------------------------------------------------------------------------
+# FUNCTION: ask
+# ---------------------------------------------------------------------------
+
+ask()
+{
+    prompt=$1
+    printf "%s" "$prompt "
+    if [ $INTERACTIVE -eq 1 ]; then
+        read answer
+    else
+        echo
+        answer=''
+    fi
+}
+
+# ---------------------------------------------------------------------------
 # FUNCTION: prompts
 # ---------------------------------------------------------------------------
 
@@ -530,8 +565,7 @@
 {
     default="y"
     prompt="Continue with installation? (y/n) [${default}] "
-    printf "%s" "$prompt "
-    read answer
+	ask "$prompt"
 
     if [ -z "${answer}" ] ; then
         answer=$default
@@ -550,8 +584,7 @@
     if [ -f ./osirismd ]; then
         default="y"
         prompt="Install management console? (y/n) [${default}] "
-        printf "%s" "$prompt "
-        read answer
+		ask "$prompt"
 
         if [ -z "${answer}" ] ; then
             answer=$default
@@ -570,11 +603,9 @@
     # prompt user for installation directory.
 
     prompt="Installation directory for binaries: [$INSTALL_DIR]"
-    printf "%s" "$prompt "
+	ask "$prompt"
 
     # read and remove any trailing slash.
-
-    read answer
     INSTALL_DIR=`expr "${INSTALL_DIR}" : '\(.*[^/]\)/*$'`
 
     if [ "$answer" != "" ]; then
@@ -586,9 +617,9 @@
         ${MKDIR} ${INSTALL_DIR}
     fi
 
-    if [ ! -d ${OSIRIS_DIR} ]; then
+    if [ ! -d ${DESTDIR}${OSIRIS_DIR} ]; then
         echo "Osiris root directory doesn't exist, creating."
-        ${MKDIR} ${OSIRIS_DIR}
+        ${MKDIR} ${DESTDIR}${OSIRIS_DIR}
     fi
 }
 
@@ -608,27 +639,27 @@
     echo ${RC_DESC}
 
     if [ -d /etc/init.d ]; then
-        INIT_D="/etc/init.d"
+        INIT_D="${DESTDIR}/etc/init.d"
     elif [ -d /etc/rc.d/init.d ]; then
-        INIT_D="/etc/rc.d/init.d"
+        INIT_D="${DESTDIR}/etc/rc.d/init.d"
     elif [ -d /etc/rc.d ]; then
-        INIT_D="/etc/rc.d"
+        INIT_D="${DESTDIR}/etc/rc.d"
     else
         INIT_D=""
     fi
 
     if [ -d /etc/rc3.d ]; then
-        RC_D="/etc"
+        RC_D="${DESTDIR}/etc"
     elif [ -d /etc/rc.d/rc3.d ]; then
-        RC_D="/etc/rc.d"
+        RC_D="${DESTDIR}/etc/rc.d"
     elif [ -f "/etc/rc.d/rc.sysvinit" ]; then
-        RC_D="/etc/rc.d"
+        RC_D="${DESTDIR}/etc/rc.d"
 
         for runlevel in 3 4 5 ; do
             dir="${RC_D}/rc${runlevel}.d"
             if [ ! -d "$dir" ]; then
-                mkdir "$dir"
-                chmod 0755 "$dir"
+                ${MKDIR} "$dir"
+                ${CHMOD} 0755 "$dir"
             fi
         done
 
@@ -637,10 +668,10 @@
     fi
 
     if [ -f ./osirisd ]; then
-        ${SED} "s#@INSTALLDIR@#${INSTALL_DIR}#" < ./linux/${OSIRISD_RC} > ${INIT_D}/osirisd.tmp
-        ${SED} "s#@OSIRISDIR@#${OSIRIS_DIR}#" < ${INIT_D}/osirisd.tmp > ${INIT_D}/osirisd
+	${MKDIR} -p ${INIT_D}
+        ${SED} "s#@INSTALLDIR@#${SBIN_DIR}#;s#@OSIRISDIR@#${OSIRIS_DIR}#" \
+			< ./linux/${OSIRISD_RC} > ${INIT_D}/osirisd
         ${CHMOD} 555 ${INIT_D}/osirisd
-        ${RM} ${INIT_D}/osirisd.tmp
 
         ${RM} -rf ${RC_D}/rc3.d/S80osirisd
         ${RM} -rf ${RC_D}/rc4.d/S80osirisd
@@ -652,10 +683,8 @@
     fi
 
     if [ $INSTALL_OSIRISM != 0 -a -f ./osirismd ]; then
-    ${SED} "s#@INSTALLDIR@#${INSTALL_DIR}#" < ./linux/${OSIRISMD_RC} > ${INIT_D}/osirismd.tmp
-    ${SED} "s#@OSIRISDIR@#${OSIRIS_DIR}#" < ${INIT_D}/osirismd.tmp > ${INIT_D}/osirismd
+    ${SED} "s#@INSTALLDIR@#${SBIN_DIR}#;s#@OSIRISDIR@#${OSIRIS_DIR}#" < ./linux/${OSIRISMD_RC} > ${INIT_D}/osirismd
         ${CHMOD} 555 ${INIT_D}/osirismd
-        ${RM} ${INIT_D}/osirismd.tmp
 
         ${RM} -rf ${RC_D}/rc3.d/S80osirismd
         ${RM} -rf ${RC_D}/rc4.d/S80osirismd
@@ -678,7 +707,7 @@
     if [ ! -f /etc/rc.conf.local ]; then
         echo "==> creating /etc/rc.conf.local"
         touch /etc/rc.conf.local
-        chmod 644 /etc/rc.conf.local
+        ${CHMOD} 644 /etc/rc.conf.local
     fi
 
     if [ ! -f /etc/rc.conf.local ]; then
@@ -903,6 +932,13 @@
 esac
 }
 
+
+# Change behaviour if we are creating packages.
+if [ -n "$DESTDIR" ]; then
+    PACKAGE_MODE=1
+    INTERACTIVE=0
+fi
+
 # ---------------------------------------------------------------------------
 # call installer functions.
 # ---------------------------------------------------------------------------


More information about the osiris-devel mailing list