Using Systemd to manage the PowerConnect Cloud Agent
The PowerConnect Cloud agent can be managed by Systemd.
Create the powerconnect systemd service file:
sudo vi /etc/systemd/system/powerconnect.service
Populate the contents as follows:
[Unit]
Description=PowerConnect Cloud agent
[Service]
Environment=POWERCONNECT_SECRET=<insert secret here>
# Environment=POWERCONNECT_MEMBERS=<insert members here>
SuccessExitStatus=143
User=powerconnect
Group=powerconnect
Type=forking
Restart=on-failure
RestartSec=30
ExecStart=/bin/bash /opt/powerconnect/bin/powerconnect.sh start
ExecStop=/bin/bash /opt/powerconnect/bin/powerconnect.sh stop
[Install]
WantedBy=multi-user.target
Set the POWERCONNECT_SECRET variable placeholder with a value as shown above
Alternatively to avoid including the POWERCONNECT_SECRET directly in the systemd service file you can create an environment file containing the secret which is only readable by the powerconnect user
touch /home/powerconnect/pcenv
Populate the environment file with the secret
POWERCONNECT_SECRET=<insert secret>
Refer to the environment file in the systemd config
[Unit] Description=PowerConnect Cloud agent [Service] EnvironmentFile=<insert env file location here> e.g. /home/powerconnect/pcenv # Environment=POWERCONNECT_MEMBERS=<insert members here> SuccessExitStatus=143 User=powerconnect Group=powerconnect Type=forking Restart=on-failure RestartSec=30 ExecStart=/bin/bash /opt/powerconnect/bin/powerconnect.sh start ExecStop=/bin/bash /opt/powerconnect/bin/powerconnect.sh stop [Install] WantedBy=multi-user.target
Uncomment and set the POWERCONNECT_MEMBERS variable if running a cluster
Reload the Systemd service:
sudo systemctl daemon-reload
Start the PowerConnect Cloud agent using Systemd:
sudo systemctl start powerconnect.service
Check the status:
systemctl status powerconnect
To have Systemd start the PowerConnect Cloud agent when the host starts up:
sudo systemctl enable powerconnect