Sort of, but it still ends up with a hard coded path.
The install/update script I have seen (and cannot remember what now), simply wrote the required text to a new file (having checked and deleted any existing file) direct to the required systemd folder (/lib/systemd/system) - no symlink required. Any paths can then be generated in the script before writing the text.
Thanks @borpin I like the āpaths can be generated in the scriptā approach. I have this now working for both the emonhub and demandshaper services, e.g: https://github.com/emoncms/demandshaper/blob/master/install.sh#L20 - the install.sh script in the demandshaper module is called from emoncms_modules.sh
Thanks for the link, that discussion did cross my mind when thinking about the /var/lib/phpfina etc locations. I will have a good read through again.
Iāve moved much of the emonhub installation process to the emonhub repo itself, replacing the existing install scripts that where emonpi specific. emonhub/install.sh at emon-pi Ā· openenergymonitor/emonhub Ā· GitHub
This script is then called from a much shorter script in the original installer directory.
FWIW, thatās an obsolete version of the spec - fifteen years old. The current version is Filesystem Hierarchy Standard
/opt/package-name for code and move data directories to /var/opt/package-name for data after installation are reasonable places for external products to be placed. If a distro packages a product and releases it, then it will typically put it under /usr with data under /var/lib
So the package should make sure it uses relative, and configurable paths to enable such changes. Ditto for its dependencies on other packages, which may live in different places on different systems. That also allows for multiple versions if the version number is in the path somewhere.
Thanks @djh that is useful to know, looks like we are on the right track then moving to /opt. I will also move the data directories to /var/opt/emon/phpfina etc (configurable of course) thanks for the tip on that. Any objections?
I still need to look the idea of supporting multiple emoncms installations on one machine as suggested by @pb66 as part of this.
Itās annoying that after you split the topic, I no longer get notification emails to tell me thereās been any activity. Short of changing discourse to also split the notifications, can I suggest that as a courtesy whenever anybody splits a topic, they post a message to the original topic stating that that is what they have done?
Iām not sure if you are using the latest Raspbian Lite image, but the readme for expanding the file system does not seem to match this image after first boot. I suspect the file system has already been expanded.
Disk /dev/mmcblk0: 14.5 GiB, 15552479232 bytes, 30375936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8b1df36f
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 96042 87851 42.9M c W95 FAT32 (LBA)
/dev/mmcblk0p2 98304 30375935 30277632 14.4G 83 Linux
Trying to run the install and I fell at the first hurdle.
[edit] decided to run it anyway. Ran fine until here where it wanted some input.
@TrystanLea, one other point as part of the install, I think this needs a 'default.config.ini` file that can be copied and changed for use but ignored by git.
At the very least a warning to the user that it is using the default config ādo you want to continueā type question.
Raspbian images now resize automatically, If you look at a virgin cmdline.txt there is a entry like init=/some/path/init_resize.sh, if you delete that before putting into a Pi, it will not resize. I think it completes the full resize on the second reboot, but if you add a 3rd partition before that it might interfere with that process. I would need to look closer at it to be sure, Iām working from memory here. You wonāt find the init= in cmdline.txt after it has resized though, it gets removed by raspi-config.
For the install script I think we should work on the basis it has been resized so need to shrink first. Goes back to where we started - do we actually need to do so?
I understand what you are saying and donāt disagree entirely. But you cannot make any assumptions and start moving partitions around unless you know the resize has run it course or you take control and block, complete or abort that resize.
sudo fdisk -l
Note end of last partition (5785599 on standard sd card)
sudo fdisk /dev/mmcblk0
enter: n->p->3
enter: 5785600
enter: default or 7626751
enter: w (write partition to disk)
fails with error, will write at reboot
sudo reboot
but itās possible that error might have been caused by unsaved changes to the partition table or saved changes not applied by partprobe (or reboot).
It could be a game of chance or bit of wrestle between the install script and the default init_resize.sh script to dictate the partitions unless the 2 are choreographed to play nicely together.