1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
#!/bin/sh
# --
# redhat-rcotrs - rc script of otrs for RedHat Linux
# Copyright (C) 2002-2003 Martin Edenhofer <martin+code@otrs.org>
# Copyright (C) 2002 Pablo Ruiz <pruiz@ip6seguridad.com>
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
# chkconfig: 2345 92 92
# description: Open Ticket Request System
# config: /etc/sysconfig/otrs
#
# load the configuration
#
if test -r /etc/sysconfig/otrs; then
. /etc/sysconfig/otrs
else
echo "ERROR: Can't find /etc/sysconfig/otrs!"
exit 5;
fi
#
# fillup PATH - just beware perl "warnings" (unimportant)
#
PATH=$PATH:
export PATH
#
# check needed files
#
if ! test -r $OTRS_POSTMASTER; then
echo "Error: $OTRS_POSTMASTER not found!"
exit 5
fi
if ! test -d $OTRS_SPOOLDIR; then
echo "Error: $OTRS_SPOOLDIR not found!"
exit 5
fi
if ! test -r $OTRS_CHECKDB; then
echo "Error: $OTRS_CHECKDB not found!"
exit 5
fi
#
# main part
#
case "$1" in
# ------------------------------------------------------
# start
# ------------------------------------------------------
start)
echo $"Starting $OTRS_PROG.."
# --
# test if apache is running..
# --
if test $OTRS_HTTP_RUNNING -gt 0; then
echo -n " Checking httpd ..."
if $OTRS_USED_WEBSERVER_TEST >/dev/null 2>&1; then
echo " done."
else
echo " failed!"
echo " --> Please start the webserver at first! (service $OTRS_USED_WEBSERVER start) <--"
exit 1
fi
else
echo " Disabled: httpd check!"
fi
# --
# check mysql, mysql init script does not have a status check...
# --
if test $OTRS_DB_RUNNING -gt 0; then
echo -n " Checking MySQL ..."
if $OTRS_USED_DB_TEST >/dev/null 2>&1; then
echo " done."
else
echo " failed."
echo " --> Please start the database at first! (service $OTRS_USED_DB start) <--"
exit 1;
fi
else
echo " Disabled: $OTRS_USED_DB check!"
fi
# --
# database connect
# --
echo -n " Checking database connect... "
if ! $OTRS_CHECKDB -s 1; then
echo " Error! "
echo " May your database isn't configured yet? "
echo ""
echo " Try the web installer to configure your database: "
echo ""
echo " -->> http://$OTRS_HOST/$OTRS_HTTP_LOCATION/installer.pl <<-- "
echo ""
echo " or configure your database with README.database (DB - Setup Example) "
exit 1;
else
echo " done."
fi
# --
# disable PostMaster.pl
# --
echo -n " Enable $OTRS_POSTMASTER ..."
if chmod 755 $OTRS_POSTMASTER; then
echo " done."
else
echo " failed."
fi
# --
# check otrs spool dir
# --
echo -n " Checking otrs spool dir... "
for i in $OTRS_SPOOLDIR/* ; do
# process old emails
if echo $i | grep -v '*' >> /dev/null; then
echo -n " Starting otrs PostMaster... ($i) "
if cat $i | $OTRS_POSTMASTER >> /dev/null 2>&1; then
rm $i && echo "(remove email) done.";
else
echo "failed."
fi
fi
done
echo " done."
# --
# Cron stuff
# --
if test $OTRS_CRON_RUNNING -gt 0; then
echo -e " Creating cronjobs (source $OTRS_CRON_DIR/*) ..."
if mkdir -p $OTRS_CRON_DIR; cd $OTRS_CRON_DIR && ls * |grep -v '.dist'|grep -v '.rpm'| xargs cat > $OTRS_CRON_TMP_FILE && crontab $OTRS_CRON_USER $OTRS_CRON_TMP_FILE ; then
echo " done."
else
echo " failed!"
exit 1
fi
else
echo " Disabled: cronjobs!"
fi
echo ""
echo " -->> http://$OTRS_HOST/$OTRS_HTTP_LOCATION/index.pl <<-- "
echo $"Final start of $OTRS_PROG.. done"
;;
# ------------------------------------------------------
# stop
# ------------------------------------------------------
stop)
echo "Shutting down OTRS "
# --
# disable PostMaster.pl
# --
echo -n " Disable $OTRS_POSTMASTER ..."
if chmod 644 $OTRS_POSTMASTER; then
echo " done."
else
echo " failed."
fi
# --
# stop cron stuff
# --
if test $OTRS_CRON_RUNNING -gt 0; then
echo -e " Shutting down cronjobs ..."
if crontab $OTRS_CRON_USER -r ; then
echo " done."
else
echo " failed!"
exit 1
fi
else
echo " Disabled: cronjobs!"
fi
echo $"Final shutdown of $OTRS_PROG.. done"
;;
# ------------------------------------------------------
# restart
# ------------------------------------------------------
restart)
$0 stop
$0 start
# Remember status and be quiet
;;
# ------------------------------------------------------
# cleanup
# ------------------------------------------------------
cleanup)
# --
# check otrs spool dir
# --
echo -n " Checking otrs spool dir... "
for i in $OTRS_SPOOLDIR/* ; do
# process old emails
if echo $i | grep -v '*' >> /dev/null ;then
echo ""
echo -n " Starting otrs PostMaster... ($i) "
if cat $i | $OTRS_POSTMASTER >> /dev/null 2>&1 ; then
echo -n "remove email... " && (rm $i || echo "failed.")
else
echo "failed."
fi
fi
done
echo " done."
;;
# ------------------------------------------------------
# status
# ------------------------------------------------------
status)
# --
# httpd
# --
/sbin/service $OTRS_USED_WEBSERVER status
# --
# mysql
# --
/sbin/service $OTRS_USED_DB status
# --
# db check
# --
echo -n "Checking database connect... "
if ! $OTRS_CHECKDB -s 1; then
echo " Error! "
echo " May your database isn't configured yet? "
else
echo "done."
fi
# --
# postmaster check
# --
echo -n "Checking $OTRS_POSTMASTER ... "
if test -x $OTRS_POSTMASTER; then
echo "(activ) done."
else
echo "(not activ) failed."
fi
# --
# spool dir
# --
echo -n "Checking otrs spool dir... "
for i in $OTRS_SPOOLDIR/* ; do
# echo old emails
echo $i | grep -v '*' > /dev/null && \
echo "" && \
echo -n " (message:$i) found! "
done
echo "done."
;;
*)
echo "Usage: $0 {start|stop|status|restart|cleanup}"
exit 1
esac
# Inform the caller not only verbosely and set an exit status.
|