Linux.com

Author Message
Joined: Aug 29, 2008
Posts: 1
Other Topics
Posted Aug 30, 2008 at 7:31:36 AM
Subject: how to make service in linux
i can run the progame when the systum start but it will stuck in accepting the connection i want to make this as a sercive which will run in background . i have tested the follow procedure for making the service 1) first i make the script "myserver.sh" that is as follows #! /bin/sh -e # Check for daemon presence test -x /usr/sbin/acpid || exit 0 # Check for ACPI support on kernel side [ -d /proc/acpi ] || exit 0 # Include acpid defaults if available OPTIONS="" if [ -f /usr/local/IPORT-CLIENT/runudps.sh ] ; then . /usr/local/IPORT-CLIENT/runudps.sh fi # Get lsb functions . /lib/lsb/init-functions . /etc/default/rcS if [ "x$VERBOSE" = "xno" ]; then MODPROBE_OPTIONS="$MODPROBE_OPTIONS -Q" export MODPROBE_OPTIONS fi # As the name says. If the kernel supports modules, it'll try to load # the ones listed in "MODULES". load_modules() { PRINTK=`cat /proc/sys/kernel/printk` [ "$VERBOSE" = no ] && echo "0 0 0 0" > /proc/sys/kernel/printk LIST=`/sbin/lsmod|awk '!/Module/ {print $1}'` # Get list of available modules LOC="/lib/modules/`uname -r`/kernel/drivers/acpi" LOC2="/lib/modules/`uname -r`/kernel/ubuntu/acpi" if [ -d $LOC ]; then MODAVAIL=`( find $LOC -type f -name "*.o" -printf "basename %f .o\n"; \ find $LOC -type f -name "*.ko" -printf "basename %f .ko\n" ) | /bin/sh` else MODAVAIL="" fi if [ -d $LOC2 ]; then MODAVAIL="$MODAVAIL `( find $LOC2 -type f -name "*.o" -printf "basename %f .o\n"; \ find $LOC2 -type f -name "*.ko" -printf "basename %f .ko\n" ) | /bin/sh`" fi if [ "$MODULES" = "all" ]; then MODULES="$MODAVAIL" fi if [ -n "$MODULES" ]; then log_begin_msg "Loading ACPI modules..." STATUS=0 for mod in $MODULES; do echo $MODAVAIL | grep -q -w "$mod" || continue if echo $LIST | grep -q -w "$mod"; then [ "$VERBOSE" != no ] && log_success_msg "Module already loaded: $mod" else if modprobe -b $mod 2>/dev/null; then [ "$VERBOSE" != no ] && log_success_msg "Loaded module: $mod" else if [ "$VERBOSE" != no ]; then log_warning_msg "Unable to load module: $mod" fi fi fi done log_end_msg $STATUS fi echo "$PRINTK" > /proc/sys/kernel/printk } case "$1" in start) [ -f /proc/modules ] && load_modules log_begin_msg "Starting ACPI services..." start-stop-daemon --start --quiet --oknodo --exec /usr/local/IPORT-CLIENT/runudps.sh -- -c /etc/acpi/events $OPTIONS log_end_msg $? ;; stop) log_begin_msg "Stopping ACPI services..." start-stop-daemon --stop --quiet --oknodo --retry 2 --exec /usr/local/IPORT-CLIENT/runudps.sh log_end_msg $? ;; restart) $0 stop sleep 1 $0 start ;; reload|force-reload) log_begin_msg "Reloading ACPI services..." start-stop-daemon --stop --signal 1 --exec /usr/local/IPORT-CLIENT/runudps.sh log_end_msg $? ;; *) log_success_msg "Usage: /etc/init.d/acpid {start|stop|restart|reload|force-reload}" exit 1 esac exit 0 after makeing the script i have run the follow command sudo update-rc.d -f myserveice.sh defaults sudo chmod +x /etc/init.d/myserveice.sh
Back to top Profile Email Website
Shashank Sharma
Joined Jan 01, 1970
Posts: 1657
Location:New Delhi, India

Other Topics
Posted: Sep 07, 2008 6:07:40 AM
Subject: how to make service in linux
Shouldn't you chmod before running the update-rc.d command? http://www.debuntu.org/how-to-manage-services-with-update-rc.d https://help.ubuntu.com/community/UbuntuBootupHowto

Coauthor of Beginning Fedora: From Novice to Professional published by Apress.

Please follow the Forum Guidelines

Back to top Profile Email Website Yahoo!
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya