Keeping shell changes persistent post upgrade?

theprez

Explorer
Joined
Oct 18, 2014
Messages
72
Morning -

I've used the following guide:

https://shebangthedolphins.net/dell_t620_fanspeed.html


To make changes to my system so that it can set the fan speed via IPMI via a script process that runs every 30 seconds and keys off CPU temps. It required new directory creation in /var/log and a new script in /usr/local/sbin to name a few.

All works fine except for when there's upgrades made to the system. Changes get reverted, script gets deleted, etc.

Is there a way or location/symlink where this can persist after an upgrade?

Thanks
 

Kris Moore

SVP of Engineering
Administrator
Moderator
iXsystems
Joined
Nov 12, 2015
Messages
1,471
You'll probably want to toss those commands into a script somewhere on your pool, and then setup an init script to run them at boot, so it survives upgrades:

 

Ixian

Patron
Joined
May 11, 2015
Messages
218
The boot partition gets completely overwritten each update, that's a byproduct of how SCALE is deployed and run.

There's no way to change that so the answer is don't put data you want to persist on boot, put it in one of your pools. You can use pre/post init tasks to script minor things like checking to see if symlinks exist and re-creating them if not.

I run a modified fan script that keys off CPU and hdd temps and adjusts the fan speeds (via ipmitool) as needed. It runs out of a directory in one of my pools and logs to a different directory in same. I don't need to mess with the boot/root partition at all this way. I launch it at boot with a simple post-init script.

A quick look at the script you linked to shows you can do basically the same thing - the script can be run from anywhere, you can change the log file path in the script to a directory under your control in one of your pools, and the tools it uses like ipmitool already exist in SCALE.

If you really want it to be controlled via a Systemd service like the page you linked outlines you can do that with a post init script too - a simple bash script that checks to see if /etc/systemd/system/ipmi.service exists, and if not copies a pre-existing ipmi.service file from your pool and re-enables the service.

Something like this would work:

Back out of any previous instance of the script running systemctl stop ipmi.service && systemctl disable ipmi.service

Create a directory on one of your pools to hold your scripts. Can be just about anything, in this example we'll use tank/scripts where tank is the pool name.

Put your fan control script ipmiservice.sh in this directory. You can also have it log here if you want.

Also copy the /etc/systemd/system/ipmi.service file you (presumably) created earlier in this directory. Make sure to adjust the paths in it to point to the new location of your ipmiservice.sh script!

Make sure it works with the new locations first - after adjusting the paths, copy ipmi.service back to /etc/systemd/system/, re-enable, and start it. Make sure the fans are being controlled like you want and that its logging to the new path.

Next, create a new script in the same directory called "check-ipmi.service.sh" with the following

Code:
#!/usr/bin/env bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
if cmp -s "${SCRIPT_DIR}/ipmi.service" /etc/systemd/system/ipmi.service
then
    echo "all good IPMI Service already enabled"
else
    echo "Updating IPMI Service..."
    cp "${SCRIPT_DIR}/ipmi.service" /etc/systemd/system/ipmi.service
    echo "Re-enabling IPMI Service"
    systemctl enable ipmi.service
    sleep 2
    systemctl start ipmi.service
fi


Make that script executable chmod +x check-ipmi.service.sh.

It's a good idea to test manually before setting up a post init task.

./check-ipmi.service.sh - when you run that, assuming your copied/renabled the service earlier, it should output "all good IPMI Service already enabled".

Now stop and disable the service again via the same commands I listed above. If the /etc/systemd/system/ipmi.service still exists, delete it.

Now run the script again chmod +x check-ipmi.service.sh.

It should see the file no longer exists (or changed), copy it over, and re-enable/re-start the service.

Once this works from the command line add a post-init task to start check-ipmi.service.sh and you're set.
 

theprez

Explorer
Joined
Oct 18, 2014
Messages
72
The boot partition gets completely overwritten each update, that's a byproduct of how SCALE is deployed and run.

There's no way to change that so the answer is don't put data you want to persist on boot, put it in one of your pools. You can use pre/post init tasks to script minor things like checking to see if symlinks exist and re-creating them if not.

I run a modified fan script that keys off CPU and hdd temps and adjusts the fan speeds (via ipmitool) as needed. It runs out of a directory in one of my pools and logs to a different directory in same. I don't need to mess with the boot/root partition at all this way. I launch it at boot with a simple post-init script.

A quick look at the script you linked to shows you can do basically the same thing - the script can be run from anywhere, you can change the log file path in the script to a directory under your control in one of your pools, and the tools it uses like ipmitool already exist in SCALE.

If you really want it to be controlled via a Systemd service like the page you linked outlines you can do that with a post init script too - a simple bash script that checks to see if /etc/systemd/system/ipmi.service exists, and if not copies a pre-existing ipmi.service file from your pool and re-enables the service.

Something like this would work:

Back out of any previous instance of the script running systemctl stop ipmi.service && systemctl disable ipmi.service

Create a directory on one of your pools to hold your scripts. Can be just about anything, in this example we'll use tank/scripts where tank is the pool name.

Put your fan control script ipmiservice.sh in this directory. You can also have it log here if you want.

Also copy the /etc/systemd/system/ipmi.service file you (presumably) created earlier in this directory. Make sure to adjust the paths in it to point to the new location of your ipmiservice.sh script!

Make sure it works with the new locations first - after adjusting the paths, copy ipmi.service back to /etc/systemd/system/, re-enable, and start it. Make sure the fans are being controlled like you want and that its logging to the new path.

Next, create a new script in the same directory called "check-ipmi.service.sh" with the following

Code:
#!/usr/bin/env bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
if cmp -s "${SCRIPT_DIR}/ipmi.service" /etc/systemd/system/ipmi.service
then
    echo "all good IPMI Service already enabled"
else
    echo "Updating IPMI Service..."
    cp "${SCRIPT_DIR}/ipmi.service" /etc/systemd/system/ipmi.service
    echo "Re-enabling IPMI Service"
    systemctl enable ipmi.service
    sleep 2
    systemctl start ipmi.service
fi


Make that script executable chmod +x check-ipmi.service.sh.

It's a good idea to test manually before setting up a post init task.

./check-ipmi.service.sh - when you run that, assuming your copied/renabled the service earlier, it should output "all good IPMI Service already enabled".

Now stop and disable the service again via the same commands I listed above. If the /etc/systemd/system/ipmi.service still exists, delete it.

Now run the script again chmod +x check-ipmi.service.sh.

It should see the file no longer exists (or changed), copy it over, and re-enable/re-start the service.

Once this works from the command line add a post-init task to start check-ipmi.service.sh and you're set.
Thanks for taking the time for such a detailed reply.

I'll give this all a try - thanks again
 

theprez

Explorer
Joined
Oct 18, 2014
Messages
72
The boot partition gets completely overwritten each update, that's a byproduct of how SCALE is deployed and run.

There's no way to change that so the answer is don't put data you want to persist on boot, put it in one of your pools. You can use pre/post init tasks to script minor things like checking to see if symlinks exist and re-creating them if not.

I run a modified fan script that keys off CPU and hdd temps and adjusts the fan speeds (via ipmitool) as needed. It runs out of a directory in one of my pools and logs to a different directory in same. I don't need to mess with the boot/root partition at all this way. I launch it at boot with a simple post-init script.

A quick look at the script you linked to shows you can do basically the same thing - the script can be run from anywhere, you can change the log file path in the script to a directory under your control in one of your pools, and the tools it uses like ipmitool already exist in SCALE.

If you really want it to be controlled via a Systemd service like the page you linked outlines you can do that with a post init script too - a simple bash script that checks to see if /etc/systemd/system/ipmi.service exists, and if not copies a pre-existing ipmi.service file from your pool and re-enables the service.

Something like this would work:

Back out of any previous instance of the script running systemctl stop ipmi.service && systemctl disable ipmi.service

Create a directory on one of your pools to hold your scripts. Can be just about anything, in this example we'll use tank/scripts where tank is the pool name.

Put your fan control script ipmiservice.sh in this directory. You can also have it log here if you want.

Also copy the /etc/systemd/system/ipmi.service file you (presumably) created earlier in this directory. Make sure to adjust the paths in it to point to the new location of your ipmiservice.sh script!

Make sure it works with the new locations first - after adjusting the paths, copy ipmi.service back to /etc/systemd/system/, re-enable, and start it. Make sure the fans are being controlled like you want and that its logging to the new path.

Next, create a new script in the same directory called "check-ipmi.service.sh" with the following

Code:
#!/usr/bin/env bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
if cmp -s "${SCRIPT_DIR}/ipmi.service" /etc/systemd/system/ipmi.service
then
    echo "all good IPMI Service already enabled"
else
    echo "Updating IPMI Service..."
    cp "${SCRIPT_DIR}/ipmi.service" /etc/systemd/system/ipmi.service
    echo "Re-enabling IPMI Service"
    systemctl enable ipmi.service
    sleep 2
    systemctl start ipmi.service
fi


Make that script executable chmod +x check-ipmi.service.sh.

It's a good idea to test manually before setting up a post init task.

./check-ipmi.service.sh - when you run that, assuming your copied/renabled the service earlier, it should output "all good IPMI Service already enabled".

Now stop and disable the service again via the same commands I listed above. If the /etc/systemd/system/ipmi.service still exists, delete it.

Now run the script again chmod +x check-ipmi.service.sh.

It should see the file no longer exists (or changed), copy it over, and re-enable/re-start the service.

Once this works from the command line add a post-init task to start check-ipmi.service.sh and you're set.

Works like a champ! Thanks again. I did have to also modify the ipmiservice to reflect the user of root and group of root but it works:

[Unit]
Description=ipmi t620 fan control
After=network.target

[Service]
Type=simple
User=root
Group=root

WorkingDirectory=/mnt/Volume1/Scripts/ipmiservice/
ExecStart=/mnt/Volume1/Scripts/ipmiservice/ipmiservice.sh
Restart=always

[Install]
WantedBy=multi-user.target
 
Top