Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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
pushd $installTarget
composer install -no
popd
# 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