Welcome, Guest. Please Login or Register
FUG-FR logo
 
  HomeHelpSearchLoginRegister  
 
rc.d scripts (Read 5232 times)
Squale
YaBB Newbies
*
Offline


Newbee on FreeBSD

Posts: 35
France
Gender: male
rc.d scripts
05. Sep 2012 at 16:58
 
Bonjour à tous,

J'ai un petit soucis avec des scripts dans rc.d.
Lorsque mon serveur démarre après un shutdown (panne électrique) les scripts que j'ai modifié ne démarre pas mais lorsque je les lance à la main par :
Code:
/usr/local/etc/rc.d/serviio_manuel start
/usr/local/etc/rc.d/serviio_web_manuel start 


tout fonctionne bien.
J'ai bien mis dans /etc/rc.conf les lignes :
Code:
serviio_manuel_enable="YES"
serviio_web_manuel_enable="YES" 



Auriez vous une idée du problème ?
Back to top
« Last Edit: 05. Sep 2012 at 19:20 by Squale »  
 
IP Logged
 
fgudin
Global Moderator
*****
Offline


PouetPouetBSD roul3z

Posts: 1552
Thonon (74)
Gender: male
Re: rc.d scripts
Reply #1 - 05. Sep 2012 at 23:04
 
Salut,

Le nom des variables parait étrange. Ce ne devrait pas plutôt être: 'serviio_enable' et 'serviio_web_enable' ?
Back to top
 
 
IP Logged
 
Squale
YaBB Newbies
*
Offline


Newbee on FreeBSD

Posts: 35
France
Gender: male
Re: rc.d scripts
Reply #2 - 06. Sep 2012 at 18:19
 
Non, en fait j'ai d'abord installé un package freeBSD qui n'a pas fonctionné correctement et j'ai donc utilisé un tar.gz que j'ai installé manuellement. c'est pour cela que j'ai différencier les variables.
installation par package :
  • serviio_enable
  • serviio_web_enable

installation manuel :
  • serviio_manuel_enable
  • serviio_web_manuel_enable
Back to top
 
 
IP Logged
 
Squale
YaBB Newbies
*
Offline


Newbee on FreeBSD

Posts: 35
France
Gender: male
Re: rc.d scripts
Reply #3 - 06. Sep 2012 at 18:24
 
Pour être plus clair, voici l'extrait de mon fichier rc.conf :
Code:
...
############################################################
# Config pour Serviio                                      #
############################################################
serviio_manuel_enable="YES"
serviio_web_manuel_enable="YES"
... 


Back to top
 
 
IP Logged
 
Squale
YaBB Newbies
*
Offline


Newbee on FreeBSD

Posts: 35
France
Gender: male
Re: rc.d scripts
Reply #4 - 06. Sep 2012 at 18:25
 
Mon fichier /usr/local/etc/rc.d/serviio_manuel :
Code:
#!/bin/sh
#
# PROVIDE: serviio_manuel
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf[.local] to enable serviio:
#
# serviio_manuel_enable="YES"

. /etc/rc.subr

# Definition des variables
app_home="/usr/local/etc/serviio"
name="serviio_manuel"
runcmd="${app_home}/bin/serviio.sh"
search_pattern="serviio"

serviio_user=${serviio_user-"dlna"}
_dirs="/var/db/serviio /var/log/serviio"
command_args="$serviio_args &"

# Definition des variables du Framework
pidfile="/var/run/${name}.pid"
rcvar="${name}_enable"
command="daemon"
flags="-f -p ${pidfile} ${runcmd}"

# Definition des Fonctions
status_cmd="app_status"

start_precmd="app_start_precmd"
start_cmd="app_start"
start_postcmd="app_start_postcmd"

stop_precmd="app_stop_precmd"
stop_cmd="app_stop"
stop_postcmd="app_stop_postcmd"

getpid()
{
	ps -aux | grep "${search_pattern}" | awk -v pid="${1:-0}" '$2==pid {print $2}'
}

getppid()
{
	ps -auxfl | awk -v ppid="${pid_run}" '$13==ppid {print $2}'
}

app_status()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	pid_run_java=$(getppid ${pid_run})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		echo "STATUS : ${name} is running (on PID ${pid_run} and Java on PID ${pid_run_java})"
	else
		echo "STATUS : ${name} is NOT running"
	fi
}

app_start_precmd()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		echo "${name} is already running !"
	else
		mkdir -p $_dirs; chown $serviio_user $_dirs
	fi
}

app_start()
{
	echo "Starting ${name}..."
	daemon ${flags}
}

app_start_postcmd()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		echo "${name} started !"
	else
		echo "${name} cannot be started"
	fi
}

app_stop_precmd()
{

}

app_stop()
{
	echo "Stopping ${name}..."
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	pid_run_java=$(getppid ${pid_run})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		kill -9 ${pid_run}
		kill -9 ${pid_run_java}
	fi
}

app_stop_postcmd()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	if [ "${pid_run}" = "" ]
	then
		[ -f ${pidfile} ] && rm -f ${pidfile}
		echo "${name} stopped"
		echo "Goodbye !"
	else
		echo "${name} cannot be stopped"
	fi
}

# Fonctions d'appel
load_rc_config ${name}
run_rc_command "$1" 

Back to top
 
 
IP Logged
 
Squale
YaBB Newbies
*
Offline


Newbee on FreeBSD

Posts: 35
France
Gender: male
Re: rc.d scripts
Reply #5 - 06. Sep 2012 at 18:26
 
Et enfin mon fichier /usr/local/etc/rc.d/serviio_web_manuel :
Code:
#!/bin/sh
#
# PROVIDE: serviio_web_manuel
# REQUIRE: serviio_manuel
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf[.local] to enable serviio:
#
# serviio_web_manuel_enable="YES"

. /etc/rc.subr

# Definition des variables
app_home="/usr/local/etc/serviio"
name="serviio_web_manuel"
runcmd="${app_home}/bin/serviio-webui.sh"
search_pattern="serviio-webui"

# Definition des variables du Framework
pidfile="/var/run/${name}.pid"
rcvar="${name}_enable"
command="daemon"
flags="-f -p ${pidfile} ${runcmd}"

# Definition des Fonctions
status_cmd="app_status"

start_precmd="app_start_precmd"
start_cmd="app_start"
start_postcmd="app_start_postcmd"

stop_precmd="app_stop_precmd"
stop_cmd="app_stop"
stop_postcmd="app_stop_postcmd"

getpid()
{
	ps -aux | grep "${search_pattern}" | awk -v pid="${1:-0}" '$2==pid {print $2}'
}

getppid()
{
	ps -auxfl | awk -v ppid="${pid_run}" '$13==ppid {print $2}'
}

app_status()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	pid_run_java=$(getppid ${pid_run})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		echo "STATUS : ${name} is running (on PID ${pid_run} and Java on PID ${pid_run_java})"
	else
		echo "STATUS : ${name} is NOT running"
	fi
}

app_start_precmd()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		echo "${name} is already running !"
	else

	fi
}

app_start()
{
	echo "Starting ${name}..."
	daemon ${flags}
}

app_start_postcmd()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		echo "${name} started !"
	else
		echo "${name} cannot be started"
	fi
}

app_stop_precmd()
{

}

app_stop()
{
	echo "Stopping ${name}..."
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	pid_run_java=$(getppid ${pid_run})
	if [ ${pid_file:-0} -eq ${pid_run:-1} ]
	then
		kill -9 ${pid_run}
		kill -9 ${pid_run_java}
	fi
}

app_stop_postcmd()
{
	[ -f ${pidfile} ] && pid_file=$(cat ${pidfile})
	pid_run=$(getpid ${pid_file})
	if [ "${pid_run}" = "" ]
	then
		[ -f ${pidfile} ] && rm -f ${pidfile}
		echo "${name} stopped"
		echo "Goodbye !"
	else
		echo "${name} cannot be stopped"
	fi
}

# Fonctions d'appel
load_rc_config ${name}
run_rc_command "$1" 

Back to top
 
 
IP Logged
 
fgudin
Global Moderator
*****
Offline


PouetPouetBSD roul3z

Posts: 1552
Thonon (74)
Gender: male
Re: rc.d scripts
Reply #6 - 07. Sep 2012 at 10:17
 
Rien qui saute aux yeux. Hum, que dit rcorder(8) ?
Code:
rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 

Back to top
 
 
IP Logged
 
olivierd
Junior Member
**
Offline


FreeBSD

Posts: 94
Vaucluse
Gender: male
Re: rc.d scripts
Reply #7 - 12. Sep 2012 at 18:08
 
Dans le script /usr/local/etc/rc.d/serviio_manuel, il manque pas le ligne REQUIRE ?

Code:
...
# PROVIDE: serviio_manuel
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown
... 

Back to top
 
 
IP Logged
 
Squale
YaBB Newbies
*
Offline


Newbee on FreeBSD

Posts: 35
France
Gender: male
Re: rc.d scripts
Reply #8 - 13. Sep 2012 at 10:43
 
Pour ce qui est du rcorder, voici le résultat de la commande :
Code:
rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 


Code:
rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
/etc/rc.d/sysctl
/etc/rc.d/hostid
/etc/rc.d/zvol
/etc/rc.d/dumpon
/etc/rc.d/ddb
/etc/rc.d/initrandom
/etc/rc.d/geli
/etc/rc.d/gbde
/etc/rc.d/encswap
/etc/rc.d/ccd
/etc/rc.d/swap1
/etc/rc.d/fsck
/etc/rc.d/root
/etc/rc.d/mdconfig
/etc/rc.d/hostid_save
/etc/rc.d/mountcritlocal
/etc/rc.d/zfs
/etc/rc.d/FILESYSTEMS
/etc/rc.d/kld
/etc/rc.d/var
/etc/rc.d/random
/etc/rc.d/adjkerntz
/etc/rc.d/atm1
/etc/rc.d/hostname
/etc/rc.d/ip6addrctl
/etc/rc.d/kldxref
/etc/rc.d/netoptions
/etc/rc.d/sppp
/etc/rc.d/ipfilter
/etc/rc.d/ipnat
/etc/rc.d/ipfs
/etc/rc.d/serial
/etc/rc.d/cleanvar
/etc/rc.d/netif
/etc/rc.d/devd
/etc/rc.d/ipsec
/etc/rc.d/atm2
/etc/rc.d/pfsync
/etc/rc.d/pflog
/etc/rc.d/pf
/etc/rc.d/stf
/etc/rc.d/ppp
/etc/rc.d/faith
/etc/rc.d/routing
/etc/rc.d/mroute6d
/etc/rc.d/nsswitch
/etc/rc.d/rtsold
/etc/rc.d/static_ndp
/etc/rc.d/static_arp
/etc/rc.d/bridge
/etc/rc.d/resolv
/etc/rc.d/route6d
/etc/rc.d/mrouted
/etc/rc.d/routed
/etc/rc.d/defaultroute
/etc/rc.d/ipfw
/etc/rc.d/NETWORKING
/etc/rc.d/netwait
/etc/rc.d/mountcritremote
/etc/rc.d/accounting
/etc/rc.d/ldconfig
/etc/rc.d/devfs
/etc/rc.d/ipmon
/etc/rc.d/mdconfig2
/etc/rc.d/newsyslog
/etc/rc.d/syslogd
/etc/rc.d/savecore
/etc/rc.d/archdep
/etc/rc.d/abi
/etc/rc.d/SERVERS
/etc/rc.d/named
/etc/rc.d/ntpdate
/etc/rc.d/rpcbind
/etc/rc.d/nfsclient
/etc/rc.d/nisdomain
/etc/rc.d/ypserv
/etc/rc.d/ypbind
/etc/rc.d/ypset
/etc/rc.d/amd
/etc/rc.d/atm3
/etc/rc.d/auditd
/etc/rc.d/tmp
/etc/rc.d/cleartmp
/etc/rc.d/dmesg
/etc/rc.d/hastd
/etc/rc.d/ipxrouted
/etc/rc.d/kerberos
/etc/rc.d/kadmind
/etc/rc.d/keyserv
/etc/rc.d/kpasswdd
/etc/rc.d/nfsuserd
/etc/rc.d/gssd
/etc/rc.d/quota
/etc/rc.d/mountd
/etc/rc.d/nfsd
/etc/rc.d/statd
/etc/rc.d/lockd
/etc/rc.d/pppoed
/etc/rc.d/pwcheck
/etc/rc.d/virecover
/etc/rc.d/DAEMON
/etc/rc.d/apm
/etc/rc.d/apmd
/etc/rc.d/bootparams
/etc/rc.d/hcsecd
/etc/rc.d/bthidd
/etc/rc.d/local
/etc/rc.d/lpd
/etc/rc.d/motd
/etc/rc.d/mountlate
/etc/rc.d/nscd
/etc/rc.d/ntpd
/etc/rc.d/powerd
/etc/rc.d/rarpd
/etc/rc.d/rctl
/etc/rc.d/sdpd
/etc/rc.d/rfcomm_pppd_server
/etc/rc.d/rtadvd
/etc/rc.d/rwho
/etc/rc.d/timed
/etc/rc.d/ugidfw
/etc/rc.d/yppasswdd
/usr/local/etc/rc.d/samba
/etc/rc.d/LOGIN
/usr/local/etc/rc.d/webmin
/usr/local/etc/rc.d/vsftpd
/usr/local/etc/rc.d/serviio_manuel
/usr/local/etc/rc.d/serviio_web_manuel
/usr/local/etc/rc.d/sabnzbd
/usr/local/etc/rc.d/rsyncd
/usr/local/etc/rc.d/php-fpm
rcorder: requirement `SYSLOG' in file `/usr/local/etc/rc.d/noip' has no providers.
/usr/local/etc/rc.d/noip
/usr/local/etc/rc.d/htcacheclean
/usr/local/etc/rc.d/ffserver
/usr/local/etc/rc.d/fail2ban
/usr/local/etc/rc.d/clamav-clamd
/usr/local/etc/rc.d/clamav-freshclam
/usr/local/etc/rc.d/apache22
/etc/rc.d/ypxfrd
/etc/rc.d/ypupdated
/etc/rc.d/wpa_supplicant
/etc/rc.d/watchdogd
/etc/rc.d/ubthidhci
/etc/rc.d/syscons
/etc/rc.d/sshd
/etc/rc.d/sendmail
/etc/rc.d/cron
/etc/rc.d/jail
/etc/rc.d/localpkg
/etc/rc.d/securelevel
/etc/rc.d/power_profile
/etc/rc.d/othermta
/etc/rc.d/nfscbd
/etc/rc.d/natd
/etc/rc.d/msgs
/etc/rc.d/moused
/etc/rc.d/mixer
/etc/rc.d/inetd
/etc/rc.d/hostapd
/etc/rc.d/gptboot
/etc/rc.d/geli2
/etc/rc.d/ftpd
/etc/rc.d/ftp-proxy
/etc/rc.d/dhclient
/etc/rc.d/bsnmpd
/etc/rc.d/bluetooth
/etc/rc.d/bgfsck
/etc/rc.d/addswap 


Comme vous pouvez le voir juste une erreur sur noip.
Back to top
 
 
IP Logged
 
David Marec
Senior Member
****
Offline



Posts: 386
Toulouse
Gender: male
Re: rc.d scripts
Reply #9 - 13. Sep 2012 at 14:11
 
Squale wrote on 05. Sep 2012 at 16:58:
Bonjour à tous,

J'ai un petit soucis avec des scripts dans rc.d.
Lorsque mon serveur démarre après un shutdown (panne électrique) les scripts que j'ai modifié ne démarre pas mais lorsque je les lance à la main par :
Code:
/usr/local/etc/rc.d/serviio_manuel start
/usr/local/etc/rc.d/serviio_web_manuel start 


tout fonctionne bien.


Si les scripts se lancent de cette façon, c'est qu'ils sont correctement configurés dans rc.conf.

vous pouvez aussi utiliser service pour les lancer:
Code:
 service serviio_web_manuel start
 


Je pense qu'ils sont lancés effectivement au démarrage, mais qu'ils échouent ensuite.
Vérifiez les logs, s'il y en a.

comme le dit Ptit0, il manque un 'required': rcorder précise que ces services démarrent bien avant nombre de services réseaux.
Back to top
« Last Edit: 13. Sep 2012 at 14:17 by David Marec »  
WWW WWW https://diaspora.lapinbilly.eu/stream https://diaspora.lapinbilly.eu/stream  
IP Logged