Commits

Zhang Huangbin committed f9bc867

Create rc scripts for iRedAPD on OpenBSD.

  • Participants
  • Parent commits db4e932

Comments (0)

Files changed (2)

File iRedMail/functions/cleanup.sh

 # Available variables for automate installation (value should be 'y' or 'n'):
 #   AUTO_CLEANUP_REMOVE_SENDMAIL
 #   AUTO_CLEANUP_REMOVE_MOD_PYTHON
-#   AUTO_CLEANUP_REPLACE_IPTABLES_RULE
+#   AUTO_CLEANUP_REPLACE_FIREWALL_RULES
 #   AUTO_CLEANUP_RESTART_IPTABLES
 #   AUTO_CLEANUP_REPLACE_MYSQL_CONFIG
 #   AUTO_CLEANUP_RESTART_POSTFIX
     echo 'export status_cleanup_remove_mod_python="DONE"' >> ${STATUS_FILE}
 }
 
-cleanup_replace_iptables_rule()
+cleanup_replace_firewall_rules()
 {
     # Get SSH listen port, replace default port number in iptable rule file.
     export sshd_port="$(grep '^Port' ${SSHD_CONFIG} | awk '{print $2}' )"
 
     ECHO_QUESTION "Would you like to use firewall rules provided by iRedMail now?"
     ECHO_QUESTION -n "File: ${IPTABLES_CONFIG}, with SSHD port: ${sshd_port}. [Y|n]"
-    read_setting ${AUTO_CLEANUP_REPLACE_IPTABLES_RULE}
+    read_setting ${AUTO_CLEANUP_REPLACE_FIREWALL_RULES}
     case $ANSWER in
         N|n ) ECHO_INFO "Skip firewall rules." ;;
         Y|y|* ) 
         ENABLED_SERVICES="iptables ${ENABLED_SERVICES}"
     fi
 
-    echo 'export status_cleanup_replace_iptables_rule="DONE"' >> ${STATUS_FILE}
+    echo 'export status_cleanup_replace_firewall_rules="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_replace_mysql_config()
     check_status_before_run cleanup_remove_mod_python
     [ X"${KERNEL_NAME}" == X'LINUX' \
         -o X"${KERNEL_NAME}" == X'OPENBSD' \
-        ] && check_status_before_run cleanup_replace_iptables_rule
+        ] && check_status_before_run cleanup_replace_firewall_rules
     [ X"${DISTRO}" == X"RHEL" ] && check_status_before_run cleanup_replace_mysql_config
     check_status_before_run cleanup_backup_scripts
     [ X"${BACKEND}" == X'PGSQL' ] && check_status_before_run cleanup_pgsql_force_password

File iRedMail/functions/iredapd.sh

     elif [ X"${DISTRO}" == X"FREEBSD" ]; then
         cp ${IREDAPD_ROOT_DIR}/iredapd/rc_scripts/iredapd.freebsd ${DIR_RC_SCRIPTS}/iredapd
     elif [ X"${DISTRO}" == X'OPENBSD' ]; then
-        cp ${IREDAPD_ROOT_DIR}/iredapd/rc_scripts/iredapd.rhel ${DIR_RC_SCRIPTS}/iredapd
+        # Create rc script
+        cat > ${DIR_RC_SCRIPTS}/iredapd <<EOF
+#!/bin/sh
+daemon='python ${IREDAPD_ROOT_DIR}/iredapd/src/iredapd.py ${IREDAPD_ROOT_DIR}/iredapd/etc/iredapd.ini'
+
+. /etc/rc.d/rc.subr
+
+rc_reload=NO
+rc_cmd \$1
+EOF
+
+        cat > ${DIR_RC_SCRIPTS}/iredapd-rr <<EOF
+#!/bin/sh
+daemon='python ${IREDAPD_ROOT_DIR}/iredapd/src/iredapd-rr.py ${IREDAPD_ROOT_DIR}/iredapd/etc/iredapd-rr.ini'
+
+. /etc/rc.d/rc.subr
+
+rc_reload=NO
+rc_cmd \$1
+EOF
+
+        chmod 0755 ${DIR_RC_SCRIPTS}/iredapd-rr
     else
         cp ${IREDAPD_ROOT_DIR}/iredapd/rc_scripts/iredapd.rhel ${DIR_RC_SCRIPTS}/iredapd
     fi
 
-    if [ X"${DISTRO}" == X'OPENBSD' ]; then
-        perl -pi -e 's#(.*)(/usr/bin/env bash)#${1}/usr/local/bin/bash#' ${DIR_RC_SCRIPTS}/iredapd
-        perl -pi -e 's#python#/usr/local/bin/python#' ${DIR_RC_SCRIPTS}/iredapd
-        perl -pi -e 's#(.*echo)(.*Starting.*)#${1} -n " iredapd"#' ${DIR_RC_SCRIPTS}/iredapd
-        perl -pi -e 's#(.*echo)(.*Stopping.*)#${1} -n " iredapd"#' ${DIR_RC_SCRIPTS}/iredapd
-    fi
-
     chmod 0755 ${DIR_RC_SCRIPTS}/iredapd
     chmod +x ${IREDAPD_ROOT_DIR}/iredapd/src/iredapd.py