Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!
Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.
Hi, I am trying to run a script using systemd, but I keep getting errors when it runs.
My script is as follows:
# this mounts a secure ftp remote path for local use #! /bin/bash curlftpfs -o ssl -o ssl_control -o no_verify_hostname -o no_verify_peer -d username:password@domain:port /mnt/ftpshare &
My systemd template is as follows:
[Unit] Description=ftp remote mount [Service] ExecStart=/home/ftpmount.sh KillMode=process [Install] WantedBy=multi-user.target
When I run
/home/ftpmount.sh
the script executes fine
but when I run the service and check the status
sudo systemctl status ftpmount -l
I get:
● ftpmount.service - ftp remote mount Loaded: loaded (/etc/systemd/system/ftpmount.service; enabled) Active: failed (Result: exit-code) since Tue 2016-11-15 22:16:18 GMT; 23s ago Process: 1568 ExecStart=/home/ftpmount.sh (code=exited, status=203/EXEC) Main PID: 1568 (code=exited, status=203/EXEC) Nov 15 22:16:18 openmediavault systemd[1]: Started ftp remote mount. Nov 15 22:16:18 openmediavault systemd[1]: ftpmount.service: main process exited, code=exited, status=203/EXEC Nov 15 22:16:18 openmediavault systemd[1]: Unit ftpmount.service entered failed state.
Can anybody help me to resolve this please
Offline
3271
Ostatnio edytowany przez uzytkownikubunt (2016-12-01 01:47:19)
Offline
Unfortunately, I still can't get it to run, with your suggestion, very frustrating spent nearly a week trying to get it to work, with or with '&' makes no difference.
Thanks again for your help.
Ostatnio edytowany przez scouseman (2016-11-16 18:19:41)
Offline
My way to mount remote resources SSH / FTP:
#!/bin/bash function dugmount { sshfs USERNAME@HOSTNAME:/home/FOLDER /media/dug echo "dug zamontowany w /media/dug ;)"; notify-send -t 2000 "dug zamontowany w /media/dug ;)"; }; function dugexit { fusermount -u /media/dug || $( killall sshfs && sudo umount /media/dug) echo "dug odmontowany ;)"; notify-send -t 2000 "dug odmontowany ;)"; }; grep 'HOSTNAME' /proc/mounts &>>/dev/null && dugexit || dugmount; exit 0;
I do not use SystemD.
Run at startup? I prefer OpenRC and Daemontools in my Gentoo, Debian will SysVinit and Daemnotools.
Maybe try to run script ftpmount.sh using /etc/rc.local
?
Offline
Thanks for your replies guys:
The solution to this as uzytkownikubunt said was to remove
# this mounts a secure ftp remote path for local use
off the top of the script and it works fine
Offline
Why don't you just use a native systemd mechanism? I have a local ftp server, it listens on 192.168.1.150:21. If I wanted to mount it via curlftpfs using your command from the script, I would type something like this:
# curlftpfs -o ssl -o ssl_control -o no_verify_hostname -o no_verify_peer -d morfik:pass@192.168.1.150:21 /mnt
Now I can see the content of my FTP, but only as root. Basically the one who starts the command is able to see the content. If you want to allow other users to see what's inside, you can use the following command:
# curlftpfs -o ssl -o ssl_control -o no_verify_hostname -o no_verify_peer -o allow_other -d morfik:pass@192.168.1.150:21 /mnt
Now, you don't write a script to mount this resource because it's madness to do such thing on systemd. Instead, just use a .mount file, in this case /etc/systemd/system/mnt.mount with the following content:
[Unit] Before=remote-fs.target [Mount] What=curlftpfs#morfik:pass@192.168.1.150:21 Where=/mnt Type=fuse Options=auto,user,uid=1000,allow_other,ssl,ssl_control,no_verify_hostname,no_verify_peer
And that's basically it. When you mount it, you get what you wanted:
# systemctl start mnt.mount # systemctl status mnt.mount --no-pager ● mnt.mount - /mnt Loaded: loaded (/etc/systemd/system/mnt.mount; static; vendor preset: enabled) Active: active (mounted) since Fri 2016-11-18 10:04:26 CET; 2min 16s ago Where: /mnt What: curlftpfs#ftp://morfik:pass@192.168.1.150:21/ Process: 129067 ExecUnmount=/bin/umount /mnt (code=exited, status=0/SUCCESS) Process: 129105 ExecMount=/bin/mount curlftpfs#morfik:pass@192.168.1.150:21 /mnt -t fuse -o user,uid=1000,allow_other,ssl,ssl_control,no_verify_hostname,no_verify_peer (code=exited, status=0/SUCCESS) Tasks: 3 (limit: 4915) CGroup: /system.slice/mnt.mount └─129116 curlftpfs morfik:pass@192.168.1.150:21 /mnt -o rw,noexec,nosuid,nodev,uid=1000,allow_other,ssl,ssl_control,no_verify_hostname,no_verify_peer Nov 18 10:04:26 morfikownia systemd[1]: Mounting /mnt... Nov 18 10:04:26 morfikownia systemd[1]: Mounted /mnt.
Offline
Thanks morfik
That work perfectly and seems much cleaner.
Thanks very much.
Offline