-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_install_daylight_status.bash
executable file
·81 lines (66 loc) · 1.86 KB
/
00_install_daylight_status.bash
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
77
78
79
80
#!/bin/bash
#h-------------------------------------------------------------------------------
#h
#h Name: install_daylight_status.bash
#h Type: Linux shell script
#h Purpose: install python and daylight_status
#h Project:
#h Usage: copy folder to target place
#h ./install_daylight_status.bash
#h Result:
#h Examples:
#h Outline:
#h Resources:
#h Platforms: Debian Linux (Raspberry Pi OS, Ubuntu)
#h Authors: peb piet66
#h Version: V1.0.0 2023-01-16/peb
#v History: V1.0.0 2022-12-09/peb first version
#h Copyright: (C) piet66 2022
#h License: http://opensource.org/licenses/MIT
#h
#h-------------------------------------------------------------------------------
MODULE='install_daylight_status.bash';
VERSION='V1.0.0'
WRITTEN='2023-01-16/peb'
#exit when any command fails
set -e
#set path constants
. `dirname $(readlink -f $0)`/00_constants
umask 000
# install python3
sudo apt install -y python3
python3 -V
#install pip3
sudo apt install -y python3-pip
#create and activate python environment
sudo apt install -y python3-venv
python3 -m venv $VIRTUAL_ENV
source $VIRTUAL_ENV/bin/activate
#newly create requirements.txt
#pip3 install pipreqs
#export PATH=$PATH:~/.local/bin
#pipreqs .
#install necessary packages
pip3 install -r requirements.txt
#display installed python packages
pip3 freeze
#install cron
function cron_add_line {
l="$1"
crontab -l
if [ $? -eq 0 ]
then
echo remove line if existing:
X=`crontab -l | sed "\:$l:d"`
crontab -r
echo "$X" | crontab -
fi
echo add new line
cat <(crontab -l) <(echo "$l") | crontab -
}
echo ''
echo installing cron-job for user $USER...
set +e
cron_add_line "@reboot $PACKET_PATH/$PACKET_NAME.bash >/dev/null 2>&1" >/dev/null 2>&1
echo ''
echo start process with: ./11_get_procid.bash