![]() |
Best way to make a startup script?
As the title says: i want to make an own script that's called on every boot (and shutdown), just like mount-sd.sh.
Why not modify mount-sd.sh?
i was using it, see here: http://talk.maemo.org/showthread.php?t=92449, but since the update to 1.0.4 this does not work very well anymore, since there were a lot of changes: https://github.com/nemomobile/sd-utils/commits/master How do i make my own script, called before the "ambiance-stuff" is executed? edit: must be executed as root |
Re: Best way to make a startup script?
what is this ambiance stuff exactly?
Check /etc/systemd/system/mount-sd@.service You can create own systemd configuration for your script and you can also bind the execution order of your service. |
Re: Best way to make a startup script?
for more info, look at http://www.freedesktop.org/wiki/Software/systemd/
|
Re: Best way to make a startup script?
Discovering systemd... I made a graph of the systemd settings, but I don't know how to interpret it yet...
Commands are : systemctl --order dot > sysgraph.dot then (after transfering the file on my Ubuntu pc): cat sysgraph.dot | dot -Tsvg > sysgraph.svg Result can be found here: http://ubuntuone.com/7jnlRCzUhnMtOgYqjSc72m |
Re: Best way to make a startup script?
I also like to use a custom mount script. Ambiences from pictures on the sdcard get lost with the new mount-sd.sh script.
I like to help you. I have build a system.service to make the custom mount. I took my old allround debug-script to do it. You can use it, should be useful for all use cases. 1. the script Name: mount-sd.custom.sh Code:
#!/bin/bash My subvolume structure for understanding the script better, At the moment I am only using ".android" and ".myfolder/Pictures". Code:
[root@jolla nemo]# btrfs sub list /media/work Code:
devel-su Name: mount-custom.service Code:
[Unit] copy it to /lib/systemd/system/mount-custom.service as root and activate it. Code:
devel-su Code:
devel-su Code:
[root@jolla nemo]# journalctl | grep mount-sd.custom Be careful and sucessful PS: my ambiences of pictures from the Picture folder are persistent, since I use that service. Thats all I have tested until now. |
Re: Best way to make a startup script?
I big thank you for this, works like a charm.
I made it even simplier as I just want my home be mounted on my sdcard, and I know it is here. [nemo@localhost ~]$ cat /usr/sbin/mount-sd-home.sh #!/bin/bash ACTION=$1 if [ "$ACTION" = "add" ]; then if [ $(mount | grep -c /mnt/sdhome) != 1 ]; then mount -o noatime,rw,autodefrag /dev/mmcblk1p1 /mnt/sdhome mount -o bind /mnt/sdhome/.home /home/nemo mount -o bind /mnt/sdhome/.android /data/sdcard fi else umount /data/sdcard umount /home/nemo umount /mnt/sdhome fi [nemo@localhost ~]$ cat /lib/systemd/system/mount-sd-home.service [Unit] Description=Handle home on sdcard After=local-fs.target RequiresMountsFor=/home [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/sbin/mount-sd-home.sh add ExecStop=/usr/sbin/mount-sd-home.sh remove [Install] WantedBy=multi-user.target Everything seems to work: - ambiences - new pictures and videos that I take are here and browsable - settings are persited between reboots A question, how did you pick the dependecies ? (After=local-fs.target RequiresMountsFor=/home) Is there a doc somewhere I could look at to understand the boot process ? Regards, Franck |
Re: Best way to make a startup script?
Quote:
Look #3 from nieldk -- I read a lot first. Quote:
http://www.freedesktop.org/software/...irectives.html https://fedoraproject.org/wiki/Systemd Yours is much easier for your needs. Mine is programmed to be flexible and for debugging. With this setting of variables it does, what yours do if you are using btrfs filesystem with subvolums ;-) : Code:
#MYDEBUG="" |
Re: Best way to make a startup script?
It won't be deleted when you don't modify system files and you do not put your files into any application or account specific directory. By modifying existing system files you can guarantee it will be wiped sooner or later in system update.
|
Re: Best way to make a startup script?
I have tried to get similar system that alci has to work. I have checked that the script is working, but when I boot the device I get this:
[root@localhost nemo]# journalctl | grep mount-sd-home.sh Mar 24 14:13:36 localhost mount-sd-home.sh[789]: mount: wrong fs type, bad option, bad superblock on /dev/mmcblk1p1, Mar 24 14:13:36 localhost mount-sd-home.sh[789]: missing codepage or helper program, or other error Mar 24 14:13:36 localhost mount-sd-home.sh[789]: In some cases useful info is found in syslog - try Mar 24 14:13:36 localhost mount-sd-home.sh[789]: dmesg | tail or so Mar 24 14:13:36 localhost mount-sd-home.sh[789]: mount: special device /mnt/sdhome/.home does not exist Mar 24 14:13:36 localhost mount-sd-home.sh[789]: mount: special device /mnt/sdhome/.android does not exist However if I use the script /usr/sbin/mount-sd-home.sh add It mounts nicely: /dev/mmcblk1p1 60G 9,3G 48G 17% /media/sdcard/2f36d7c2-46bf-4c14-b8cc-2defaad1b529 /dev/mmcblk1p1 60G 9,3G 48G 17% /mnt/sdhome /dev/mmcblk1p1 60G 9,3G 48G 17% /home/nemo /dev/mmcblk1p1 60G 9,3G 48G 17% /data/sdcard If I mount the sd card with the script, I am also still not able to see the pictures in my gallery after I take them. I can see them with file browser however and even open them in gallery from file browser. |
Re: Best way to make a startup script?
@hopey
What filesystem are you using? May be a driver module is missing, it should be added to the dependencies of the service. I am using btrfs like SailfishOS. If you mount it manually with the script, its to late for the tracker. You can do a Code:
tracker-control -es |
All times are GMT. The time now is 18:06. |
vBulletin® Version 3.8.8