Last active
May 20, 2020 09:20
-
-
Save brantfaircloth/7273320 to your computer and use it in GitHub Desktop.
CentOS init script for the ghost blogging platform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# ghost - this script starts the ghost blogging package | |
# | |
# chkconfig: - 95 20 | |
# description: ghost is a blogging platform built using javascript \ | |
# and running on nodejs | |
# | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
# Source networking configuration. | |
. /etc/sysconfig/network | |
# Check that networking is up. | |
[ "$NETWORKING" = "no" ] && exit 0 | |
home="/home/ghost/ghost-0.3.3/" | |
exec="/usr/bin/node index.js >> /home/ghost/ghost.log &" | |
prog="ghost" | |
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog | |
lockfile=/var/lock/subsys/$prog | |
start() { | |
#[ -x $exec ] || exit 5 | |
echo -n $"Starting $prog: " | |
# if not running, start it up here, usually something like "daemon $exec" | |
export NODE_ENV=production | |
cd $home | |
daemon --user=ghost $exec | |
retval=$? | |
echo | |
[ $retval -eq 0 ] && touch $lockfile | |
return $retval | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
# stop it here, often "killproc $prog" | |
pid=`ps -u $prog -fw | grep $prog | grep -v " grep " | awk '{print $2}'` | |
kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure | |
retval=$? | |
echo | |
[ $retval -eq 0 ] && rm -f $lockfile | |
return $retval | |
} | |
restart() { | |
stop | |
start | |
} | |
my_status() { | |
local base pid lock_file= | |
base=${1##*/} | |
# get pid | |
pid=`ps -u $prog -fw | grep $prog | grep -v " grep " | awk '{print $2}'` | |
if [ -z "${lock_file}" ]; then | |
lock_file=${base} | |
fi | |
# See if we have no PID and /var/lock/subsys/${lock_file} exists | |
if [[ -z "$pid" && -f /var/lock/subsys/${lock_file} ]]; then | |
echo $"${base} dead but subsys locked" | |
return 2 | |
fi | |
if [ -z "$pid" ]; then | |
echo $"${base} is stopped" | |
return 3 | |
fi | |
if [ -n "$pid" ]; then | |
echo $"${base} (pid $pid) is running..." | |
return 0 | |
fi | |
} | |
rh_status() { | |
# run checks to determine if the service is running or use generic status | |
my_status $prog | |
} | |
rh_status_q() { | |
rh_status >/dev/null 2>&1 | |
} | |
case "$1" in | |
start) | |
rh_status_q && exit 0 | |
$1 | |
;; | |
stop) | |
rh_status_q || exit 0 | |
$1 | |
;; | |
restart) | |
$1 | |
;; | |
status) | |
rh_status | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|status}" | |
exit 2 | |
esac | |
exit $? |
Set up this script and now I see garbage written in place of it:
/dev/mapper/VolGroup-lv_root / ext4 rw 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs rw,rootcontext="system_u:object_r:tmpfs_t:s0" 0 0
/dev/sda1 /boot ext4 rw 0 0
and a bunch of NULL NULL NULL NULL NULL
Maybe I configured it to dump some sort of log info into itself lol
It used to work just fine for a little white, and executed fine on boot as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! Thank you for this gist!
to add script execution at start time:
sudo chkconfig --level 345 ghost on