Ask Your Question
1

init script that requires network to run

asked 2012-04-25 12:54:51 -0600

kdma gravatar image

Hello, i made a little script named FTPbackup that needs network connection to work, after many google searches i've hit a wall since i dont know what is the problem.(the script works fine if i start it manually when network is on)

Here is the chkconfig header

#!/bin/sh
#
# FTPBACKUP Mantiene una copia di una cartella su un FTP aggiornandola ad ogni boot
#
# chkconfig: 5 99 17
# description: Simple FTP uploader
#              

### BEGIN INIT INFO
# Provides: FTPBACKUP
# Required-Start: $network 
# Required-Stop: 
# Should-Start: $network
# Should-Stop: 
# Default-Start: 5
# Default-Stop: 0 1 2 3 4 6
# Short-Description: Boot time daemon
# Description: enable service provided by daemon
### END INIT INFO

and this is the error log as you can see the script says service not found because it runs just before the network connection.

Apr 25 16:40:02 Andromeda NetworkManager[879]: <info> (wlan0): supplicant interface state: starting -> ready
Apr 25 16:40:02 Andromeda NetworkManager[879]: NetworkManager[879]: <info> (wlan0): supplicant interface state: starting -> ready
Apr 25 16:40:02 Andromeda NetworkManager[879]: <info> (wlan0): device state change: unavailable -> disconnected (reason 'supplicant-available') [20 30 42]
Apr 25 16:40:02 Andromeda NetworkManager[879]: NetworkManager[879]: <info> (wlan0): device state change: unavailable -> disconnected (reason 'supplicant-available') [20 30 42]
Apr 25 16:40:02 Andromeda NetworkManager[879]: <info> (wlan0): supplicant interface state: ready -> inactive
Apr 25 16:40:02 Andromeda NetworkManager[879]: NetworkManager[879]: <info> (wlan0): supplicant interface state: ready -> inactive
Apr 25 16:40:02 Andromeda kernel: [   33.794353] iscsi: registered transport (iser)
Apr 25 16:40:02 Andromeda kernel: [   33.828821] libcxgbi:libcxgbi_init_module: tag itt 0x1fff, 13 bits, age 0xf, 4 bits.
Apr 25 16:40:02 Andromeda kernel: [   33.828833] libcxgbi:ddp_setup_host_page_size: system PAGE 4096, ddp idx 0.
Apr 25 16:40:02 Andromeda kernel: [   33.831855] Chelsio T3 iSCSI Driver cxgb3i v2.0.0 (Jun. 2010)
Apr 25 16:40:02 Andromeda kernel: [   33.833375] iscsi: registered transport (cxgb3i)
Apr 25 16:40:02 Andromeda kernel: [   33.850599] Chelsio T4 iSCSI Driver cxgb4i v0.9.1 (Aug. 2010)
Apr 25 16:40:02 Andromeda kernel: [   33.852107] iscsi: registered transport (cxgb4i)
Apr 25 16:40:02 Andromeda kernel: [   33.871036] cnic: Broadcom NetXtreme II CNIC Driver cnic v2.5.8 (Jan 3, 2012)
Apr 25 16:40:02 Andromeda kernel: [   33.879859] Broadcom NetXtreme II iSCSI Driver bnx2i v2.7.0.3 (Jun 15, 2011)
Apr 25 16:40:02 Andromeda kernel: [   33.879988] iscsi: registered transport (bnx2i)
Apr 25 16:40:02 Andromeda kernel: [   33.904081] iscsi: registered transport (be2iscsi)
Apr 25 16:40:03 Andromeda iscsid: iSCSI logger with pid=1046 started!
Apr 25 16:40:03 Andromeda iscsid[956]: Starting iscsid: [  OK  ]#015[  OK  ]
Apr 25 16:40:03 Andromeda systemd[1]: PID file /var/run/iscsid.pid not readable (yet?) after start.
Apr 25 16:40:03 Andromeda ftpbackup[980]: Starting FTPBACKUP: lftp: www 0catch com: Name or service not known
Apr 25 16:40:03 Andromeda ftpbackup[980]: [FAILED]
Apr 25 16:40:03 Andromeda systemd ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2012-04-25 16:23:38 -0600

ztank1013 gravatar image

I see you would like to run the ftp backup script once every boot and your approach looks correct but there are alternatives.

I would try with cron. Use @reboot special syntax to let crond run your script every time your machine boots

@reboot /path/to/FTPbackup

Run

man 5 crontab

command for more info about crontab syntax.

Another way still available in fedora 16 (not sure about f17) is the /etc/rc.local file. You will have to create the file by hand if it is not there and add a line to call your script. rc.local file will be executed by root once a boot after all the runlevel scripts already have run.

edit flag offensive delete link more
0

answered 2012-04-26 13:40:21 -0600

Akshay gravatar image

updated 2012-04-26 13:51:42 -0600

HOST=X.X.X.X

USERNAME=XXXX

PASS=XXXX

tar -czf

FOLDERTOBE_BACKEDUP.tar.gz

FOLDERTOBE_BACKEDUP/*

ftp -n -i $HOST <<-EOF

user $USERNAME $PASS

pwd

delete

FOLDERTOBE_BACKEDUP.tar.gz

mput

FOLDERTOBE_BACKEDUP.tar.gz

bye

This script will let you do all these things

Create a .TAR of the folder to be backed up
Upload the folder to the FTP server
Delete the previous night's backup

NOTE : X.X.X.X represents destination IP Address

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-04-25 12:54:51 -0600

Seen: 790 times

Last updated: Apr 26 '12