i found a solution that works.
the script now has a longer sleep (90s) so im sure it runs when sakis3g is connected.
its so composed:
sudo nano /etc/init.d/upload
Code: Select all
#*********************************************************
#! /bin/sh
# /etc/init.d/upload
### BEGIN INIT INFO
# Provides: upload
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: A simple script which will start / stop a program a boot / shutdown.
### END INIT INFO
case "$1" in
start)
sleep 90
echo "Upload to FTP"
# run application you want to start
sudo /opt/upload/upload
;;
stop)
echo "Terminate process, also not necessary"
# kill application you want to stop
;;
*)
echo "Usage: /etc/init.d/upload {start|stop}"
exit 1
;;
esac
exit 0
#*********************************************************
sudo chmod 755 /etc/init.d/upload
sudo /etc/init.d/upload start
sudo /etc/init.d/upload stop
sudo update-rc.d upload defaults
this script runs one other script:
-> sudo /opt/upload/upload
Code: Select all
sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /data
find /data -type f -exec curl -u ftpuser:ftppasswrd --ftp-create-dirs -T {} ftp://ftpurl/{} \;
rm -r /data/* -f -v
it works, but i want to add more "intelligence".
how can manage the last part of the script: rm -r /data/* -f -v
i want do execute it only if the ftp upload process it's all fine. How can i set conditions?
thanks