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 [b]/etc/rc.local[/b]
?
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
Time (s) | Query |
---|---|
0.00014 | SET CHARSET latin2 |
0.00006 | SET NAMES latin2 |
0.00150 | SELECT u.*, g.*, o.logged FROM punbb_users AS u INNER JOIN punbb_groups AS g ON u.group_id=g.g_id LEFT JOIN punbb_online AS o ON o.ident='3.135.202.38' WHERE u.id=1 |
0.00095 | REPLACE INTO punbb_online (user_id, ident, logged) VALUES(1, '3.135.202.38', 1732739768) |
0.00059 | SELECT * FROM punbb_online WHERE logged<1732739468 |
0.00072 | SELECT topic_id FROM punbb_posts WHERE id=306944 |
0.00010 | SELECT id FROM punbb_posts WHERE topic_id=29144 ORDER BY posted |
0.00055 | SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM punbb_topics AS t INNER JOIN punbb_forums AS f ON f.id=t.forum_id LEFT JOIN punbb_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=29144 AND t.moved_to IS NULL |
0.00005 | SELECT search_for, replace_with FROM punbb_censoring |
0.00165 | SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM punbb_posts AS p INNER JOIN punbb_users AS u ON u.id=p.poster_id INNER JOIN punbb_groups AS g ON g.g_id=u.group_id LEFT JOIN punbb_online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=29144 ORDER BY p.id LIMIT 0,25 |
0.00093 | UPDATE punbb_topics SET num_views=num_views+1 WHERE id=29144 |
Total query time: 0.00724 s |