Browse Source

[config] suppression du runtime directory, utilisation de /var/lib/pyheatpump

Maxime Alves LIRMM@home 3 years ago
parent
commit
d2c1e5aeda
2 changed files with 21 additions and 10 deletions
  1. 18
    7
      config/pre-exec.sh
  2. 3
    3
      config/pyheatpump_supervise.service

+ 18
- 7
config/pre-exec.sh View File

1
 #!/bin/sh
1
 #!/bin/sh
2
+REPO_DIR=/opt/pyHeatpump
3
+LIB_DIR=/var/lib/pyheatpump
4
+
2
 
5
 
3
-# If directory exists don't run the script
4
 # cd /opt/pyheatpump git clone https://git.yannweb.net/cli/pyHeatpump.git
6
 # cd /opt/pyheatpump git clone https://git.yannweb.net/cli/pyHeatpump.git
5
-[ ! -d /opt/pyHeatpump/ ] && echo "Missing /opt/pyHeatpump/" && exit 1;
6
-[ ! -d /run/pyheatpump/ ] && echo "Missing /run/pyheatpump/" && exit 1;
7
+[ ! -d $REPO_DIR ] \
8
+  && echo "Missing $REPO_DIR" \
9
+  && exit 1;
7
 
10
 
8
-[ -f /run/pyheatpump/pyheatpump.sqlite3 ] && [ -f /run/pyheatpump/pyheatpump.ini ] \
9
-        && echo "Incorrect runtime directory" && exit 1;
11
+[ ! -d /var/lib/pyheatpump ] && mkdir --mode 0700 /var/lib/pyheatpump
12
+# If files already exist don't var/lib the script
13
+[ -f $LIB_DIR/pyheatpump.sqlite3 ] && [ -f $LIB_DIR/pyheatpump.ini ] \
14
+  && exit 0;
10
 
15
 
11
 # Database initialization
16
 # Database initialization
12
-sqlite3 -init /opt/pyHeatpump/db/pyheatpump.sql /run/pyheatpump/pyheatpump.sqlite3 .quit \
17
+if [ ! -f $LIB_DIR/pyheatpump.sqlite3 ];
18
+then
19
+  sqlite3 -init $REPO_DIR/db/pyheatpump.sql $LIB_DIR/pyheatpump.sqlite3 .quit \
13
     || (echo "Failed to initialize database" && exit 1);
20
     || (echo "Failed to initialize database" && exit 1);
21
+fi
14
 
22
 
15
 # Default configuration setup
23
 # Default configuration setup
16
-cp /opt/pyHeatpump/config/pyheatpump.prod.ini.dist /run/pyheatpump/pyheatpump.ini \
24
+if [ ! -f $LIB_DIR/pyheatpump.ini ];
25
+then
26
+  cp $REPO_DIR/config/pyheatpump.prod.ini.dist $LIB_DIR/pyheatpump.ini \
17
     || (echo "Failed to initialized configuration file" && exit 1);
27
     || (echo "Failed to initialized configuration file" && exit 1);
28
+fi
18
 
29
 
19
 exit 0;
30
 exit 0;

+ 3
- 3
config/pyheatpump_supervise.service View File

4
 
4
 
5
 [Service]
5
 [Service]
6
 Type=simple
6
 Type=simple
7
-RuntimeDirectory=pyheatpump
8
-WorkingDirectory=/run/pyheatpump
7
+StateDirectory=pyheatpump
8
+WorkingDirectory=/var/lib/pyheatpump
9
 Environment="LOGLEVEL=INFO"
9
 Environment="LOGLEVEL=INFO"
10
 ExecStartPre=/opt/pyHeatpump/config/pre-exec.sh
10
 ExecStartPre=/opt/pyHeatpump/config/pre-exec.sh
11
 ExecStart=/usr/bin/env pyheatpump supervise --since
11
 ExecStart=/usr/bin/env pyheatpump supervise --since
12
 KillMode=mixed
12
 KillMode=mixed
13
 TimeoutStopSec=30sec
13
 TimeoutStopSec=30sec
14
-PrivateTmp=true
14
+PrivateTmp=false

Loading…
Cancel
Save