Skip to content

Instantly share code, notes, and snippets.

@Aramgutang
Created December 13, 2011 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aramgutang/1469790 to your computer and use it in GitHub Desktop.
Save Aramgutang/1469790 to your computer and use it in GitHub Desktop.
An rc.d script for controlling Virtuoso
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/virtuoso
VIRTUOSO_DATA=${VIRTUOSO_DATA-/var/lib/virtuoso/db}
VIRTUOSO_CONF=${VIRTUOSO_CONF-${VIRTUOSO_DATA}/virtuoso.ini}
VIRTUOSO_ARGS=${VIRTUOSO_ARGS-}
PID=$(get_pid virtuoso-t)
case $1 in
start)
stat_busy "Starting Virtuoso"
# Check if data folder exists or create it if it doesn't
[ -d $VIRTUOSO_DATA ] || mkdir -p $VIRTUOSO_DATA &>/dev/null
if [ ! $? = 0 ]; then
stat_fail
echo "Could not create Virtuoso data directory at $VIRTUOSO_DATA"
exit 1
fi
# Virtuoso needs to be run from its data directory
cd $VIRTUOSO_DATA &>/dev/null
if [ ! $? = 0 ]; then
stat_fail
echo "Could not access Virtuoso data directory at $VIRTUOSO_DATA"
exit 1
fi
# Check if the configuration file exists
if [ ! -f $VIRTUOSO_CONF ]; then
stat_fail
echo "Could not find Virtuoso configuration file at $VIRTUOSO_CONF"
exit 1
fi
# Make sure the data folder is writeable
if [ ! -w $VIRTUOSO_DATA ]; then
stat_fail
echo "Insufficient privileges to run Virtuoso at $VIRTUOSO_DATA"
exit 1
fi
# Start Virtuoso
[ -z $PID ] && virtuoso-t -c $VIRTUOSO_CONF +wait $VIRTUOSO_ARGS
if [ $? = 0 ]; then
add_daemon virtuoso
stat_done
else
stat_fail
exit 1
fi
;;
stop)
stat_busy "Stopping Virtuoso"
[ -n "$PID" ] && kill $PID &>/dev/null
if [ $? = 0 ]; then
rm_daemon virtuoso
stat_done
else
stat_fail
exit 1
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
stat_busy "Checking Virtuoso status";
ck_status virtuoso
;;
*)
echo "usage: $0 {start|stop|restart|status}"
exit 1
esac
@Aramgutang
Copy link
Author

The file was written with Arch Linux in mind. To use, download file to /etc/rc.d/virtuoso, refine the data directory by setting VIRTUOSO_DATA in /etc/conf.d/virtuoso, if desired, and create a virtuoso.ini file in the data directory. Then use the rc.d command to control the Virtuoso daemon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment