下载 4.1.4 的 rpm 包
tar xvf Apache_OpenOffice_4.1.4_Linux_x86-64_install-rpm_zh-CN.tar.gz
cd zh-CN/RPMS/
rpm -ivh *.rpm
编写系统服务脚本:
vi /etc/rc.d/init.d/openoffice
内容如下:
#!/bin/sh
# chkconfig: 35 65 80
# description: script for OpenOffice
### BEGIN INIT INFO
# Provides: openoffice
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenOffice Server
# Description: OpenOffice Server
### END INIT INFO
PID=`ps ax | grep soffice | grep sh | awk '{print $1;}'`
RETVAL=0
case "$1" in
start)
if [[ $PID != "" ]]; then
echo "OpenOffice Server is already running."
else
echo -n "Starting OpenOffice Server ..."
/opt/openoffice4/program/soffice -headless -accept="socket,host=0.0.0.0,port=8100;urp;" -nofirststartwizard &
RETVAL=$?
echo
fi
;;
stop)
if [[ $PID != "" ]]; then
echo -n "Stopping OpenOffice Server ..."
ps ax | grep soffice | grep sh | awk '{print $1;}' | xargs kill >/dev/null
RETVAL=$?
echo
else
echo "OpenOffice Server is not running."
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
status)
if [[ $PID != "" ]]; then
echo "OpenOffice is running ..."
else
echo "OpenOffice is not running ..."
fi
;;
*)
echo "Usage: $0 {start | stop | restart | status}"
RETVAL=1
;;
esac
exit $RETVAL
配置系统服务:
chmod +x /etc/rc.d/init.d/openoffice
systemctl enable openoffice
可以使用如下命令:
【启动】systemctl start openoffice 或者 service openoffice start
【停止】systemctl stop openoffice 或者 service openoffice stop
【重启】systemctl restart openoffice 或者 service openoffice restart
【查看状态】systemctl status openoffice 或者 service openoffice status