-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
76 lines (72 loc) · 3.36 KB
/
run.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Install pai
if [[ -f /opt/paradox/config/user.py ]]; then
cp /opt/paradox/config/user.py /root/user.py
rm -rf /opt/paradox
git clone https://github.com/jpbarraca/pai.git /opt/paradox
pip3 install -r /opt/paradox/requirements.txt
sleep 30
mv /root/user.py /opt/paradox/config/user.py
mkdir -p /opt/paradox/logs/
else
rm -rf /opt/paradox
git clone https://github.com/jpbarraca/pai.git /opt/paradox
pip3 install -r /opt/paradox/requirements.txt
sleep 30
cp /opt/paradox/config/user.py.sample /opt/paradox/config/user.py
echo -e "CONNECTION_TYPE = 'IP'" >> /opt/paradox/config/user.py
if [[ -n $IP_CONNECTION_HOST ]]; then
echo -e "IP_CONNECTION_HOST = '$IP_CONNECTION_HOST'" >> /opt/paradox/config/user.py
fi
if [[ -n $IP_CONNECTION_PASSWORD ]]; then
echo -e "IP_CONNECTION_PASSWORD = b'$IP_CONNECTION_PASSWORD'" >> /opt/paradox/config/user.py
fi
if [[ -n $IP_CONNECTION_SITEID ]]; then
echo -e "IP_CONNECTION_SITEID = '$IP_CONNECTION_SITEID'" >> /opt/paradox/config/user.py
fi
if [[ -n $IP_CONNECTION_EMAIL ]]; then
echo -e "IP_CONNECTION_EMAIL = '$IP_CONNECTION_EMAIL'" >> /opt/paradox/config/user.py
fi
if [[ -n $MQTT_ENABLE ]]; then
echo -e "MQTT_ENABLE = $MQTT_ENABLE" >> /opt/paradox/config/user.py
fi
if [[ -n $MQTT_HOST ]]; then
echo -e "MQTT_HOST = '$MQTT_HOST'" >> /opt/paradox/config/user.py
fi
if [[ -n $MQTT_PORT ]]; then
echo -e "MQTT_PORT = $MQTT_PORT" >> /opt/paradox/config/user.py
fi
if [[ -n $MQTT_USERNAME ]]; then
echo -e "MQTT_USERNAME = '$MQTT_USERNAME'" >> /opt/paradox/config/user.py
fi
if [[ -n $MQTT_PASSWORD ]]; then
echo -e "MQTT_PASSWORD = '$MQTT_PASSWORD'" >> /opt/paradox/config/user.py
fi
if [[ -n $PASSWORD ]]; then
echo -e "PASSWORD = '$PASSWORD'" >> /opt/paradox/config/user.py
else
echo -e "PASSWORD = None" >> /opt/paradox/config/user.py
fi
if [[ -n $LOGGING_FILE ]]; then
mkdir -p /opt/paradox/logs/
echo -e "LOGGING_FILE = '/opt/paradox/logs/$LOGGING_FILE'" >> /opt/paradox/config/user.py
fi
fi
# Configure cron
if [[ ! -f /var/spool/cron/crontabs/root ]]; then
mv /crontab /var/spool/cron/crontabs/root
fi
touch /etc/crontab /etc/cron.d/* /var/spool/cron/crontabs/* /var/log/cron.log
chmod 0600 /var/spool/cron/crontabs/root
# Temp fix to enable support for home-assistant
#sed -i "s/ARM_AWAY='arm'.*/armed_home='arm_stay', armed_away='arm', armed_sleep='arm_sleep', disarmed='disarm')/g" /opt/paradox/paradox/interfaces/mqtt_interface.py
#sed -i "s/alarm='triggered', stay_arm='armed_away', arm='armed_away', sleep_arm='armed_home', disarm='disarmed')/alarm='triggered', stay_arm='armed_home', arm='armed_away', sleep_arm='armed_sleep', disarm='disarmed')/g" /opt/paradox/paradox/interfaces/mqtt_interface.py
#sed -i 's/DISARMED/disarmed/g' /opt/paradox/paradox/interfaces/mqtt_interface.py;
#sed -i 's/DISARM/disarmed/g' /opt/paradox/paradox/interfaces/mqtt_interface.py;
#sed -i 's/NIGHT_ARM/armed_sleep/g' /opt/paradox/paradox/interfaces/mqtt_interface.py;
#sed -i 's/AWAY_ARM/armed_away/g' /opt/paradox/paradox/interfaces/mqtt_interface.py;
#sed -i 's/STAY_ARM/armed_home/g' /opt/paradox/paradox/interfaces/mqtt_interface.py;
#sed -i 's/ALARM_TRIGGERED/triggered/g' /opt/paradox/paradox/interfaces/mqtt_interface.py
# Use supervisord to start all processes
echo -e "Starting supervisord"
supervisord -c /etc/supervisor/conf.d/supervisord.conf