Newer
Older
#!/usr/bin/env bash
set -e
installTarget=/usr/share/fan-ctrl-php
# check for php and composer
if ! which php > /dev/null 2>&1 || ! which composer > /dev/null 2>&1; then
echo 'php and composer have to be installed in order to run fan-ctrl-php'
exit 1;
fi
# copy app, bin, composer.json, composer.lock to /usr/share/fan-ctrl-php
mkdir -p $installTarget
cp -r app bin composer.json composer.lock $installTarget
# install composer dependencies
# create symlink to bin/fan-ctrl in /usr/bin/
ln -s $installTarget/bin/fan-ctrl /usr/bin/fan-ctrl
# install fan-ctrl.service in /etc/systemd/system/
{
echo '[Unit]'
echo 'Description=A fan control service written in php'
echo ''
echo '[Service]'
echo 'User=root'
echo 'WorkingDirectory='$installTarget
echo 'ExecStart=/usr/bin/fan-ctrl daemon'
echo 'Restart=always'
echo ''
echo '[Install]'
echo 'WantedBy=multi-user.target'
} > /etc/systemd/system/fan-ctrl.service
echo Fan Control PHP successfully installed. Enable the service with \$ systemctl enable fan-ctrl.service
if ! test -f /etc/fan-ctrl.php; then
echo To create a configuration file and test the fans use \$ fan-ctrl config
fi