#!/bin/sh # # script-fu: Starts the GIMP script fu server # # Version: @(#) /etc/init.d/script-fu 1.0 # # chkconfig: 2345 90 10 # description: Starts and stops the Gimp Script-FU Server at boot time and \ # shutdown. It also takes care of (re-)generating font lists. # # processname: script-fu # config: /etc/sysconfig/script-fu # hide: false # Source function library. . /etc/init.d/functions if [ -e /etc/sysconfig/script-fu ]; then . /etc/sysconfig/script-fu fi umask 133 prog=script-fu # Make sure that xfs has "/" as the CWD cd / # screen number is arbitrarily chosen to not conflict with existing # installations. THIS IS NOT **YOUR** DISPLAY, it is the virtual display # used by Xvfb when running the script fu server. SCREENUM=24 DISPLAY=:$SCREENUM.0 TMP=/var/tmp SF_PORT=10008 LOG_PATH="/var/log/httpd/script-fu-log" ERR_LOG_PATH="/var/log/httpd/script-fu-errs" NET_FU_PATH='/var/www/html/net-fu' GIMPRC="$NET_FU_PATH/etc/gimprc_user" CHKFONTPATH="/usr/sbin/chkfontpath" buildfontlist() { pushd . &> /dev/null for d in $(/usr/sbin/chkfontpath --list | cut -f 2 -d ':') ;do if [ -d "$d" ]; then cd $d # Check if we need to rerun mkfontdir NEEDED=no if ! [ -e fonts.dir ]; then NEEDED=yes elif [ "$(find . -type f -cnewer fonts.dir 2>/dev/null)" != "" ];then NEEDED=yes fi if [ "$NEEDED" = "yes" ]; then rm -f fonts.dir &>/dev/null if ls | grep -i "\.tt[cf]$" &>/dev/null; then # TrueType fonts found... ttmkfdir -d . -o fonts.scale mkfontcache . &>/dev/null mkfontdir . &>/dev/null [ -e fonts.dir ] && chmod 644 fonts.scale fonts.dir fi if [ "$(ls |egrep -iv '\.tt[cf]$|^fonts\.|^encodings\.')" != "" ]; then # This directory contains fonts that are not TrueType... mkfontcache . &>/dev/null mkfontdir . &>/dev/null [ -e fonts.dir ] && chmod 644 fonts.dir fi fi fi done popd &> /dev/null } start_gimp() { ret=0 if [ ! -e /var/lock/subsys/script-fu ]; then gimp --display $DISPLAY --gimprc $GIMPRC --no-interface --batch "(extension-script-fu-server 1 $SF_PORT \"$LOG_PATH\")" "(gimp-quit 0)" 1>$ERR_LOG_PATH 2>&1 & ret=$? [ $ret -eq 0 ] && touch /var/lock/subsys/script-fu fi return $ret } start_xvfb() { ret=0 if [ ! -e /var/lock/subsys/xvfb ]; then if [ -L /usr/X11R6/bin/X ]; then if ! [ -d $TMP/.script-fu ]; then mkdir $TMP/.script-fu fi Xvfb :$SCREENUM -fp tcp/localhost:7100 -screen 0 1280x1024x8 -pixdepths 3 27 -fbdir $TMP/.script-fu & ret=$? [ $ret -eq 0 ] && touch /var/lock/subsys/xvfb sleep 2 fi fi return $ret } start() { if [ -x /usr/X11R6/bin/Xvfb ]; then echo -n "Starting Framebuffer X server: " start_xvfb [ $? != 0 ] && echo_failure || echo_success echo fi echo -n "Adding freefonts to font path: " xset -display $DISPLAY fp+ $NET_FU_PATH/fonts/Type1/freefont if [ $? != 0 ]; then echo_failure else $CHKFONTPATH -a $NET_FU_PATH/fonts/Type1/freefont [ $? != 0 ] && echo_failure || echo_success fi echo echo -n "Adding SHAREWARE ATM Fonts to font path: " xset -display $DISPLAY fp+ $NET_FU_PATH/fonts/Type1/sharefont if [ $? != 0 ]; then echo_failure else $CHKFONTPATH -a $NET_FU_PATH/fonts/Type1/sharefont [ $? != 0 ] && echo_failure || echo_success fi echo echo -n "Rehash font path: " xset fp rehash [ $? != 0 ] && echo_failure || echo_success echo echo -n "Starting Gimp Script-Fu Server: " start_gimp [ $? != 0 ] && echo_failure || echo_success echo return $ret } stop() { echo -n "Shutting down Gimp Server: " killproc script-fu 1>/dev/null 2>&1 ret=$? [ "$ret" -eq 0 ] && success $"$base shutdown" || failure $"$base shutdown" [ $ret -eq 0 ] && rm -f /var/lock/subsys/script-fu echo if [ -e /var/lock/subsys/xvfb ]; then echo -n "Removing freefonts from font path: " xset -display $DISPLAY fp- $NET_FU_PATH/fonts/Type1/freefont 1>/dev/null 2>&1 if [ $? != 0 ]; then echo_failure else $CHKFONTPATH -r $NET_FU_PATH/fonts/Type1/freefont 1>/dev/null 2>&1 [ $? != 0 ] && echo_failure || echo_success fi echo echo -n "Removing SHAREWARE ATM Fonts from font path: " xset -display $DISPLAY fp- $NET_FU_PATH/fonts/Type1/sharefont 1>/dev/null 2>&1 if [ $? != 0 ]; then echo_failure else $CHKFONTPATH -r $NET_FU_PATH/fonts/Type1/sharefont 1>/dev/null 2>&1 [ $? != 0 ] && echo_failure || echo_success fi echo echo -n "Rehash font path: " xset fp rehash [ $? != 0 ] && echo_failure || echo_success echo fi echo -n "Shutting down Framebuffer X server: " killproc Xvfb ret=$? [ $ret -eq 0 ] && rm -f /var/lock/subsys/xvfb echo return $ret } rhstatus() { status Xvfb status script-fu } reload() { # if [ -f /var/lock/subsys/xfs ]; then # echo -n $"Reloading $prog: " # [ -x /usr/sbin/chkfontpath ] && buildfontlist # killproc xfs -USR1 # ret=$? # echo # return $ret # else stop start # fi } restart() { echo $"Restarting $prog:" stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; condrestart) [ -f /var/lock/subsys/xvfb ] && [ -f /var/lock/subsys/script-fu ] && reload || : [ -f /var/lock/subsys/xfs ] && reload || : ;; status) rhstatus ;; *) echo $"Usage: $prog {start|stop|status|restart|reload|condrestart}" exit 1 esac exit $?