Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
SAMBA_DIR=/opt/samba
TRACKER_DIR="$SAMBA_DIR/var/tracker"
DBUS_PIDFILE="$SAMBA_DIR/var/run/dbus"
dbus_env() {
if [ ! -d "$TRACKER_DIR" ] ;
then mkdir -p "$TRACKER_DIR"
fi
export DBUS_SESSION_BUS_ADDRESS="unix:path=$INSTALLDIR/var/run/spotlight.ipc"
export HOME="$TRACKER_DIR"
export TRACKER_USE_LOG_FILES=1
export TRACKER_SPARQL_BACKEND=bus
}
start_dbus() {
printf "Starting dbus:"
PID=`dbus-daemon --config-file="$INSTALLDIR/etc/dbus-session.conf" --print-pid --fork`
echo $PID > "$DBUS_PIDFILE"
sleep 2
echo " [ok]"
}
stop_dbus() {
printf "Stopping dbus:"
if [ -f "$DBUS_PIDFILE" ] ; then
kill `cat "$DBUS_PIDFILE"`
rm "$DBUS_PIDFILE"
fi
echo " [stopped]"
}
start_tracker() {
printf "Starting Tracker:"
tracker-control -s > /dev/null 2>&1
if [ $? -eq 0 ] ; then
echo " [ok]"
else
echo " [failed]"
fi
}
start_samba() {
printf "Starting Samba:"
"$SAMBA_DIR/bin/smbd"
if [ $? -eq 0 ] ; then
echo " [ok]"
else
echo " [failed]"
fi
}
stop_samba() {
printf "Stopping Samba:"
pkill smbd
echo " [stopped]"
}
case "$1" in
start)
dbus_env
start_dbus
start_tracker
start_samba
;;
stop)
stop_samba
stop_dbus
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment