summarylogtreecommitdiffstats
path: root/ethoscope-node.install
blob: 0184d8a23c323af27507e3209775831e25e5f24c (plain)
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
## arg 1:  the new package version
#pre_install() {
	# do something here
#}

# arg 1:  the new package version
post_install() {

    #setting the bare installation folder as safe.directory
    git config --system --add safe.directory /srv/git/ethoscope.git

    #echo "changing the remote GIT source to local BARE created during installation"
    cd /opt/ethoscope
    git remote set-url origin /srv/git/ethoscope.git
    git checkout dev
    
    #installing python modules
    cd /opt/ethoscope/src/node/ && pip install -e . --break-system-packages
    cd /opt/ethoscope/src/ethoscope && pip install -e . --break-system-packages  
    
    echo "enabling NODE specific systemd service files"
    systemctl enable ethoscope_node.service ethoscope_update_node.service ethoscope_backup.service ethoscope_video_backup.service 
    echo "enabling the GIT server on the node and NTP service"
    systemctl enable git-daemon.socket ntpd.service 
    
    #changing hostname on node
    hostnamectl set-hostname node
    
    #setting host settings on node
    echo "127.0.0.1    node" > /etc/hosts

    echo "PLEASE REBOOT NOW."
}

## arg 1:  the new package version
## arg 2:  the old package version
#pre_upgrade() {
	# do something here
#}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
    echo "changing the remote GIT source to local BARE created during installation"
    cd /opt/ethoscope
    git remote set-url origin /srv/git/ethoscope.git

    #setting branch
    git checkout dev

    cd /opt/ethoscope/src/node && pip install -e . --break-system-packages
    cd /opt/ethoscope/src/ethoscope && pip install -e . --break-system-packages
}

# arg 1:  the old package version
pre_remove() {
    echo "disabling systemd service files"
    systemctl stop ethoscope_node.service ethoscope_update_node.service ethoscope_backup.service ethoscope_video_backup.service
    systemctl disable ethoscope_node.service ethoscope_update_node.service ethoscope_backup.service ethoscope_video_backup.service
    systemctl stop git-daemon.socket
    systemctl disable git-daemon.socket

}

# arg 1:  the old package version
post_remove() {
    #removes the git directorie just in case
    rm -rf /opt/ethoscope
    rm -rf /srv/git/ethoscope.git
}