For a service script to be recognized by chkconfig on RHEL 4 systems, it must include specific metadata comments in the header section. These special comments define:
- Service dependencies (
chkconfiglines) - Process description (
descriptionline) - Runlevel configuration
Here's the required header format with working examples:
#!/bin/sh
#
# chkconfig: 2345 90 10
# description: OpenOffice headless server
# processname: soffice
# pidfile: /var/run/soffice.pid
The chkconfig line contains three critical values:
# chkconfig: <start_priority> <stop_priority> <runlevels>
Here's your modified script with proper chkconfig support:
#!/bin/sh
#
# chkconfig: 2345 90 10
# description: OpenOffice headless server
# processname: soffice
# pidfile: /var/run/soffice.pid
soffice_start() {
if [ -x /opt/openoffice.org2.4/program/soffice ]; then
echo "Starting Open Office as a Service"
/opt/openoffice.org2.4/program/soffice \
-headless -accept="socket,host=0.0.0.0,port=8100;urp;StarOffice.ServiceManager" \
-nofirststartwizard &
echo $! > /var/run/soffice.pid
else
echo "Error: Could not find the soffice program. Cannot Start SOffice."
fi
}
soffice_stop() {
if [ -f /var/run/soffice.pid ]; then
echo "Stopping Openoffice"
kill -9 $(cat /var/run/soffice.pid) 2> /dev/null
rm -f /var/run/soffice.pid
else
echo "Error: PID file not found. Using killall fallback."
[ -x /usr/bin/killall ] && /usr/bin/killall soffice 2> /dev/null
fi
}
case "$1" in
'start')
soffice_start
;;
'stop')
soffice_stop
sleep 2
;;
'restart')
soffice_stop
sleep 5
soffice_start
;;
*)
echo "usage: $0 start|stop|restart"
esac
- Save the script as
/etc/init.d/soffice - Set executable permissions:
chmod +x /etc/init.d/soffice - Add to chkconfig:
chkconfig --add soffice - Verify:
chkconfig --list soffice
If issues persist after adding the metadata:
# Verify script syntax
bash -n /etc/init.d/soffice
# Check LSB compliance
lsb_release -a
# Manual runlevel symlink creation
ln -s /etc/init.d/soffice /etc/rc3.d/S90soffice
ln -s /etc/init.d/soffice /etc/rc0.d/K10soffice
For a service script to work with chkconfig on RHEL/CentOS systems, it must contain special LSB (Linux Standard Base) headers and follow specific conventions. The error "service does not support chkconfig" occurs when these requirements aren't met.
Here's how to modify your OpenOffice service script to be chkconfig-compatible:
#!/bin/sh
#
# chkconfig: 345 90 10
# description: OpenOffice headless server
# processname: soffice
# config: /etc/openoffice.cfg
soffice_start() {
if [ -x /opt/openoffice.org2.4/program/soffice ]; then
echo "Starting Open Office as a Service"
/opt/openoffice.org2.4/program/soffice \
-headless -accept="socket,host=0.0.0.0,port=8100;urp;StarOffice.ServiceManager" \
-nofirststartwizard &
else
echo "Error: Could not find the soffice program. Cannot Start SOffice."
fi
}
1. chkconfig header (# chkconfig: 345 90 10):
345: Runlevels where service should start90: Start priority (higher numbers start later)10: Stop priority (higher numbers stop earlier)
2. Other required metadata:
description: Brief service descriptionprocessname: Main process nameconfig: Optional configuration file path
After modifying the script:
# Copy to init.d
sudo cp soffice /etc/init.d/
sudo chmod +x /etc/init.d/soffice
# Add to chkconfig
sudo chkconfig --add soffice
# Verify
sudo chkconfig --list soffice
For services with dependencies, add LSB headers like:
### BEGIN INIT INFO
# Provides: soffice
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: OpenOffice headless service
# Description: Provides OpenOffice as headless server on port 8100
### END INIT INFO
If issues persist:
- Verify script has execute permissions (
chmod +x) - Check for syntax errors (
bash -n /etc/init.d/soffice) - Test script manually before chkconfig integration
- Confirm LSB headers are at the very beginning of the file