I was trying to remount a connection with a .sh script after reboot and it didn’t work. I have tried with (contrab, init.d, rc.d ,etc) Has anyone done it?
What is the command and what is the error?
I am trying to get a connection back when I reboot via sftp or ftp with another local server.
First via ftp using (curlftpfs commands)
curlftpfs -o allow_other user:pass@my-ip /my/path
then I added in fstab
curlftpfs#ftp://user:pass@my-ip/ /my/path fuse defaults 0 0
The connection is mounted but after reboot it doesn’t with fstab modification.
Then after try another way by this script
#!/bin/sh
Run-level Startup script for curlftpfs
chkconfig: 345 91 19
description: Startup/Shutdown the curlftpfs
FTP user, password, and host (you can specify the port also eg. ftp.example.com:2002)
ftpUser=user
ftpPass=mypass
ftpHost=my-ip
Mounted to folder
mPath=“/my/path”
Create the mounted to dir if doesn’t exist
if [ ! -d $mPath ]; then
mkdir -p $mPath
fi
case “$1” in
start)
curlftpfs $ftpHost $mPath -o user=$ftpUser:$ftpPass,allow_other
;;
stop)
fusermount -u $mPath
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo “Usage: $0 start|stop|restart|reload”
exit 1
esac
exit 0
This works too but when I try to run this script on every reboot it doesn’t.
For this try by contrab
1-
chmod +x my-script.sh
2-
crontab -e
3-
@reboot sh /my/local/my-script.sh
So I was trying in various ways but I can’t get the script to run on each reboot either.
I just wanted to know if anyone has made a script.sh run on every reboot.
Cheers
First thing to test is that your script can without user environment (like additional paths or something else)
Good way of testing this is crontab per minute and make sure you output everything to a file like script.sh > error.log 2>&1
right in cron
If that works in regular cron it should work in @reboot. While I am not sure if @reboot is disabled now in favour of systemd events.