|
Michael Thomas |
4869198 |
--- cyphesis-0.5.15/cyphesis.init.orig 2006-09-26 14:33:12.000000000 -0700
|
|
Michael Thomas |
4869198 |
+++ cyphesis-0.5.15/cyphesis.init 2007-12-18 15:57:12.000000000 -0800
|
|
Michael Thomas |
4869198 |
@@ -23,29 +23,35 @@
|
|
Michael Thomas |
6a90090 |
start() {
|
|
Michael Thomas |
6a90090 |
# Start the daemon.
|
|
Michael Thomas |
6a90090 |
|
|
Michael Thomas |
6a90090 |
+ if selinuxenabled ; then
|
|
Michael Thomas |
6a90090 |
+ /usr/sbin/semanage port -a -t cyphesis_port_t -p tcp 6767 &>/dev/null || :
|
|
Michael Thomas |
6a90090 |
+ /usr/sbin/semanage port -a -t cyphesis_port_t -p tcp 6769 &>/dev/null || :
|
|
Michael Thomas |
6a90090 |
+ /usr/sbin/semanage port -a -t cyphesis_port_t -p udp 32771 &>/dev/null || :
|
|
Michael Thomas |
6a90090 |
+ fi
|
|
Michael Thomas |
6a90090 |
+
|
|
Michael Thomas |
6a90090 |
# Make sure postgres superuser exists
|
|
Michael Thomas |
4869198 |
- if ! su $POSTGRESUSER -c true >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
+ if ! runuser $POSTGRESUSER -c true >/dev/null 2>&1; then
|
|
Michael Thomas |
6a90090 |
echo
|
|
Michael Thomas |
4869198 |
echo $"Could not check for running PostgreSQL database."
|
|
Michael Thomas |
4869198 |
return 1
|
|
Michael Thomas |
4869198 |
fi
|
|
Michael Thomas |
4869198 |
|
|
Michael Thomas |
4869198 |
# Make sure postgres is running
|
|
Michael Thomas |
4869198 |
- if ! su $POSTGRESUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
+ if ! runuser $POSTGRESUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
echo $"PostgreSQL server is not running."
|
|
Michael Thomas |
4869198 |
return 1
|
|
Michael Thomas |
4869198 |
fi
|
|
Michael Thomas |
4869198 |
|
|
Michael Thomas |
4869198 |
# Make sure the user we are going to run as exists
|
|
Michael Thomas |
4869198 |
- if ! su $CYPHESISUSER -c true >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
+ if ! runuser $CYPHESISUSER -c true >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
echo $"Cannot find user $CYPHESISUSER to run cyphesis service."
|
|
Michael Thomas |
4869198 |
return 1
|
|
Michael Thomas |
4869198 |
fi
|
|
Michael Thomas |
4869198 |
|
|
Michael Thomas |
4869198 |
# Make sure the user has a postgres account
|
|
Michael Thomas |
4869198 |
- if ! su $CYPHESISUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
+ if ! runuser $CYPHESISUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
echo -n $"Creating PostgreSQL account: "
|
|
Michael Thomas |
4869198 |
- su $POSTGRESUSER -c "createuser -A -d -q -R $CYPHESISUSER" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
+ runuser $POSTGRESUSER -c "createuser -A -d -q -R $CYPHESISUSER" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
RETVAL=$?
|
|
Michael Thomas |
4869198 |
if [ $RETVAL -eq 0 ]; then
|
|
Michael Thomas |
4869198 |
echo_success
|
|
Michael Thomas |
4869198 |
@@ -58,10 +64,10 @@
|
|
Michael Thomas |
4869198 |
fi
|
|
Michael Thomas |
4869198 |
|
|
Michael Thomas |
4869198 |
# Make sure the database exists
|
|
Michael Thomas |
4869198 |
- if ! su $CYPHESISUSER -c "psql -c \"\" cyphesis" >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
+ if ! runuser $CYPHESISUSER -c "psql -c \"\" cyphesis" >/dev/null 2>&1; then
|
|
Michael Thomas |
4869198 |
# Create the database
|
|
Michael Thomas |
4869198 |
echo -n $"Creating PostgreSQL database: "
|
|
Michael Thomas |
4869198 |
- su $CYPHESISUSER -c "createdb -q cyphesis" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
+ runuser $CYPHESISUSER -c "createdb -q cyphesis" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
RETVAL=$?
|
|
Michael Thomas |
4869198 |
if [ $RETVAL -eq 0 ]; then
|
|
Michael Thomas |
4869198 |
echo_success
|
|
Michael Thomas |
4869198 |
@@ -73,7 +79,7 @@
|
|
Michael Thomas |
4869198 |
echo
|
|
Michael Thomas |
4869198 |
# Populate it with rules
|
|
Michael Thomas |
4869198 |
echo -n $"Loading database with rules: "
|
|
Michael Thomas |
4869198 |
- su $CYPHESISUSER -c "cyloadrules" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
+ runuser $CYPHESISUSER -c "cyloadrules" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
RETVAL=$?
|
|
Michael Thomas |
4869198 |
if [ $RETVAL -eq 0 ]; then
|
|
Michael Thomas |
4869198 |
echo_success
|
|
Michael Thomas |
4869198 |
@@ -88,7 +94,7 @@
|
|
Michael Thomas |
4869198 |
echo -n $"Starting cyphesis: "
|
|
Michael Thomas |
4869198 |
|
|
Michael Thomas |
4869198 |
# Run the server, in self daemonising mode
|
|
Michael Thomas |
4869198 |
- su $CYPHESISUSER -c "/usr/bin/cyphesis --cyphesis:daemon=true" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
+ runuser $CYPHESISUSER -c "/usr/bin/cyphesis --cyphesis:daemon=true" >/dev/null 2>&1
|
|
Michael Thomas |
4869198 |
RETVAL=$?
|
|
Michael Thomas |
4869198 |
if [ $RETVAL -eq 0 ]; then
|
|
Michael Thomas |
4869198 |
echo_success
|
|
Michael Thomas |
6a90090 |
@@ -96,8 +102,24 @@
|
|
Michael Thomas |
6a90090 |
else
|
|
Michael Thomas |
6a90090 |
echo_failure
|
|
Michael Thomas |
6a90090 |
echo
|
|
Michael Thomas |
6a90090 |
+ return $RETVAL
|
|
Michael Thomas |
6a90090 |
fi
|
|
Michael Thomas |
6a90090 |
echo
|
|
Michael Thomas |
6a90090 |
+
|
|
Michael Thomas |
6a90090 |
+ if [ "$POPULATE_WORLD" == "1" ] ; then
|
|
Michael Thomas |
6a90090 |
+ echo -n $"Populating cyphesis world: "
|
|
Michael Thomas |
6a90090 |
+
|
|
Michael Thomas |
6a90090 |
+ # Populate the world with game data
|
|
Michael Thomas |
4869198 |
+ runuser $CYPHESISUSER -c "/usr/bin/cyclient" >/dev/null 2>&1
|
|
Michael Thomas |
6a90090 |
+ RETVAL=$?
|
|
Michael Thomas |
6a90090 |
+ if [ $RETVAL -eq 0 ]; then
|
|
Michael Thomas |
6a90090 |
+ echo_success
|
|
Michael Thomas |
6a90090 |
+ else
|
|
Michael Thomas |
6a90090 |
+ echo_failure
|
|
Michael Thomas |
6a90090 |
+ fi
|
|
Michael Thomas |
6a90090 |
+ echo
|
|
Michael Thomas |
6a90090 |
+ fi
|
|
Michael Thomas |
6a90090 |
+
|
|
Michael Thomas |
6a90090 |
return $RETVAL
|
|
Michael Thomas |
6a90090 |
}
|
|
Michael Thomas |
6a90090 |
|
|
Michael Thomas |
6a90090 |
@@ -107,7 +129,13 @@
|
|
Michael Thomas |
6a90090 |
killproc cyphesis
|
|
Michael Thomas |
6a90090 |
RETVAL=$?
|
|
Michael Thomas |
6a90090 |
echo
|
|
Michael Thomas |
6a90090 |
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/cyphesis
|
|
Michael Thomas |
6a90090 |
+ if [ $RETVAL -eq 0 ] ; then
|
|
Michael Thomas |
6a90090 |
+ rm -f /var/lock/subsys/cyphesis
|
|
Michael Thomas |
6a90090 |
+ /usr/sbin/semanage port -d -t cyphesis_port_t -p tcp 6767 &>/dev/null || :
|
|
Michael Thomas |
6a90090 |
+ /usr/sbin/semanage port -d -t cyphesis_port_t -p tcp 6769 &>/dev/null || :
|
|
Michael Thomas |
6a90090 |
+ /usr/sbin/semanage port -d -t cyphesis_port_t -p udp 32771 &>/dev/null || :
|
|
Michael Thomas |
6a90090 |
+ fi
|
|
Michael Thomas |
6a90090 |
+
|
|
Michael Thomas |
6a90090 |
return $RETVAL
|
|
Michael Thomas |
6a90090 |
}
|
|
Michael Thomas |
6a90090 |
|