summarylogtreecommitdiffstats
path: root/cellframe-dashboard.install
blob: 9599386d79ba907b3e01485b7fcc6a074cb4c3e9 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
post_install() {
    echo "+++ Generating node configuration file..."
    cp /opt/cellframe-node/share/configs/cellframe-node.cfg.tpl /opt/cellframe-node/etc/cellframe-node.cfg
    chmod 0666 /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{DEBUG_MODE}|false|' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{PREFIX}|/opt/cellframe-node|g' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{AUTO_ONLINE}|true|' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{SERVER_ENABLED}|true|' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{SERVER_ADDR}|0.0.0.0|' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{SERVER_PORT}|8079|' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{NOTIFY_SRV_ADDR}|127.0.0.1|' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i 's|{NOTIFY_SRV_PORT}|8080|' /opt/cellframe-node/etc/cellframe-node.cfg
    sed -i "s|{DB_DRIVER}|mdbx|" /opt/cellframe-node/etc/cellframe-node.cfg
    
    echo "+++ Generating network configuration files..."
    for _networks in mileena KelVPN Backbone subzero
    do
        cp /opt/cellframe-node/share/configs/network/$_networks.cfg.tpl /opt/cellframe-node/etc/network/$_networks.cfg
        sed -i 's|{NODE_TYPE}|full|' /opt/cellframe-node/etc/network/$_networks.cfg
    done
    
    systemctl daemon-reload

    echo "+++ Creating symbolic links for executables..."
    for _executables in cellframe-node-cli cellframe-node-tool cellframe-node
	do
		chmod a+x /opt/cellframe-node/bin/$_executables
		ln -sf /opt/cellframe-node/bin/$_executables /usr/local/bin/$_executables
	done

    chmod +x /opt/cellframe-dashboard/bin/*
    ln -sf /opt/cellframe-dashboard/bin/Cellframe-Dashboard /usr/local/bin/Cellframe-Dashboard
    
    mkdir -p /opt/cellframe-node/var/{run,lib/wallet,lib/global_db,lib/plugins,log}

    cat << EOF

    ########################################################################
    ########################################################################
    ##                                                                    ##
    ##  Cellframe Dashboard - The super application with Cellframe node   ##
    ##  ______________________________________________________________    ##
    ##                                                                    ##
    ##  To start:                                                         ##
    ##                                                                    ##
    ##   1. systemctl enable --now cellframe-node.service                 ##
    ##                                                                    ##
    ##   1. systemctl enable --now cellframe-dashboard.service            ##
    ##                                                                    ##
    ##   2. Launch Cellframe Dashboard from your applications             ##
    ##                                                                    ##
    ##                                                                    ##
    ########################################################################
    ########################################################################

EOF

}

pre_upgrade() {
    for _active in cellframe-dashboard cellframe-node
    do
        systemctl is-active --quiet $_active.service && systemctl stop $_active.service && echo "+++ Stopped $_active service..."
    done
}

post_upgrade() {
    systemctl daemon-reload
    for _active in cellframe-dashboard cellframe-node
    do
        systemctl is-enabled --quiet $_active.service && systemctl start $_active.service && echo "+++ Started $_active service..."
    done
}

pre_remove() {
    for _active in cellframe-dashboard cellframe-node
    do
        systemctl is-active --quiet $_active.service && systemctl stop --quiet $_active.service && echo "+++ Stopped $_active service..."
        systemctl is-enabled --quiet $_active.service && systemctl disable --quiet $_active.service && echo "+++ Disabled $_active service..."
    done
}


post_remove() {
    systemctl daemon-reload
    echo "+++ Removing symbolic links..."
    for _executables in cellframe-node-cli cellframe-node-tool cellframe-node
	do
		unlink /usr/local/bin/$_executables
	done

    unlink /usr/local/bin/Cellframe-Dashboard
}