RE: service already in /etc/rc6.d, why no stopping service when reboot...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You need to create file /var/lock/subsys/<your service name> when you start
the service, as existance of this file checked by /etc/rc.d/rc script to
determine if service actually runs. 

Pavel.

> -----Original Message-----
> From: Steven Shiau [mailto:steven@xxxxxxxxxxx]
> Sent: Mon, July 21, 2003 1:44 PM
> To: shrike-list@xxxxxxxxxx
> Subject: service already in /etc/rc6.d, why no stopping 
> service when reboot...
> 
> 
> Hi!
> I wrote a service to create and clean a swap file when boot 
> or reboot a
> machine.
> By using "chkconfig --add mkswapfile", it's successfully added to the
> /etc/rcx.d. I do saw S15mkswapfile in /etc/rc3.d, and K85mkswapfile in
> /etc/rc6.d, and it DO run successfully when my machine 
> booted. BUT when
> the machine rebooted, it did NOT run K85mkswapfile at all. I can NOT
> even see anything, it seems that init just skip it.
> Does anyone know why ?
> 
> Thanks in advance.
> 
> Ps. The mkswapfile script is:
> -------------------------
> #!/bin/sh
> # mkswapfile    This shell script takes care of starting and stopping
> #               the mkswapfile.
> #
> # chkconfig: 2345 15 85
> # description: mkswapfile is a script to create swap file for 
> DRBL client.
> #
> # Author: Blake, Kuo-Lien Huang
> # License: GPL
> # Description:
> #  start|stop drbl cluster mode
> #  disk is used to install the cluster node (the same as drblcd) on
> local disk
> #
> # Modified by Steven Shiau <steven@xxxxxxxxxxx> to use it in DRBL for
> Redhat.
> # This file is borrowed from Knoppix (http://www.knoppix.org).
> 
> # The MaxSwapSize (MB)
> # MaxSwapSize=512
> # Source function library.
> . /etc/rc.d/init.d/functions
> 
> # Source mkswapfile configuration.
> if [ ! -f /etc/sysconfig/mkswapfile ]; then
>     exit 0
> fi
> 
> . /etc/sysconfig/mkswapfile
> 
> 
> newswapfile() {
> 
>   # Maximum swap file size
>   MaxSwapSize=$1
>   # Find exist swap partitions
>   found=0
>   for p in `/sbin/fdisk -l | grep "Linux swap" | cut -d" " -f1`
>   do
>     /sbin/swapon $p
>     found=1
>   done
>   if [ $found -eq 1 ]; then
>     echo "Use the exist swap partition."
>     exit;
>   fi
> 
>   # Create swap files in exist partitions
>   #TMP="/tmp/mkswapfile.$$"
>   TMP=$(mktemp /tmp/mkswapfile.XXXXXX)
>   total_swap_size=0
>   for p in `/sbin/fdisk -l | grep "^\/dev\/" | awk '{ if($2=="*" &&
> $6!="f" && $6!="0") print $1; if($2!="*" && $5!="f" && $5!="0") print
> $1; }'`
>   do
>     d="/tmp/${p##*/}"
>     f="$d/drbl-cluster.swap"
>     mkdir -p $d
>     # mount the partition, check the size, create the swap file
>     if mount -o umask=000,rw $p $d; then
>       ## check the partition size, use 60% for swap
>       AVAIL=$(df -m $d | awk '/^\/dev\//{print $4}')
>       cat <<-EOF > $TMP
> $AVAIL * 3 / 5
> quit
> EOF
>       AVAIL=`bc $TMP`
>       if [ $AVAIL -gt $MaxSwapSize ]; then AVAIL=$MaxSwapSize; fi
>       if [ $AVAIL -gt 60 ]; then
>         ## create the swap file
>         dd if=/dev/zero of="$f" bs=1000k count="$AVAIL"
>         chmod 600 $f 2>/dev/null
>         /sbin/mkswap -v1 "$f" && /sbin/swapon -v "$f"
>       fi
>     fi
>     # check if the total_swap_size is greater than $MaxSwapSize
>     total_swap_size=`expr $AVAIL + $total_swap_size`
>     if [ $total_swap_size -ge $MaxSwapSize ]; then break; fi
>   done
>     if [ $total_swap_size -eq 0 ]; then
>       echo "Can NOT find available partition, NO swap file 
> will be created!"
>     fi
>   rm -f $TMP
> }
> 
> rmswapfile() {
>   for p in `/sbin/fdisk -l | grep "^\/dev\/" | awk '{ if($2=="*" &&
> $6!="f" && $6!="0") print $1; if($2!="*" && $5!="f" && $5!="0") print
> $1; }'`
>   do
>     d="/tmp/${p##*/}"
>     f="$d/drbl-cluster.swap"
>     if [ -f $f ]; then
>       /sbin/swapoff -v "$f"
>       rm -f $f
>     fi
>     if [ "$(mount | grep "$d")" != "" ]; then
>       umount $d
>     fi
>   done
> }
> 
> ###
> case "$1" in
>   "start")
>     #echo "Creating swap file (Upto $maxswapsize Mb) if the 
> harddisk is
> available... This may take few minitues."
>     action $"Starting mkswapfile services: " $0 newswapfile 
> $maxswapsize &
>     ;;
>   "stop")
>     #echo "Removing swap file... This may take few minitues."
>     action $"Stoping mkswapfile services: " $0 rmswapfile
>     ;;
>   "newswapfile")
>     newswapfile $maxswapsize
>     ;;
>   "rmswapfile")
>     rmswapfile
>     ;;
>   restart)
>     $0 stop
>     $0 start
>     ;;
>   *)
>     echo $"Usage: $0 {start|stop|restart}"
>     exit 1
> esac
> 
> exit 0
> --------------------------------
> -- 
> Please AVOID distributing documents in WORD, EXCEL or 
> POWERPOINT format.
> [Chinese Big5] 請避免散佈WORD, EXCEL 或是 POWERPOINT格式的檔案.
> See http://www.fsf.org/philosophy/no-word-attachments.html
> and http://www.cyut.edu.tw/~ckhung/published/997nodoc.shtml
> ----------------------------------
> Steven Shiau
> E-mail: steven@xxxxxxxxxxx; steven@xxxxxxxxxxxx
> 
> 
> 
> 
> -- 
> Shrike-list mailing list
> Shrike-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/shrike-list
> 


-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux