summarylogtreecommitdiffstats
path: root/craftycontroller.install
blob: c75fc88681d737e2504296cb3f17f983552ada7e (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
post_install() {
    echo 'Creating user for Crafty Controller...'
    
    useradd -M -r -s /bin/bash -b '/opt/craftycontroller' crafty
    
    echo 'Setting Permissions...'
    
    chown -R crafty:crafty '/opt/craftycontroller'
    
    echo 'Creating the Python Virtual Enviorment...'
    
    cd '/opt/craftycontroller'
    
    python3 -m venv craftycontroller
    
    echo 'Warning: About to run first-time Launch!'
    
    echo 
    
    echo 'Prepare for prompt, for first-time configuration!'
    
    echo 'Crafty Controller/Crafty Web, is located at: /opt/craftycontroller'
    
    echo '  '
    
    echo 'Starting...'
    
    echo '3...'
    
    echo '2..'
    
    echo '1.'
    
    sudo -u crafty /usr/bin/bash -c /opt/craftycontroller/start.sh && export success=1 & exit 0 
    
    if [ ! -z "$success" ]; then
        export success="0"
    fi
    
    if [ "$success" == "0" ]; then
        echo 'Initialisation failed, Please run /opt/craftycontroller/start.sh as crafty user.'
    fi
}

post_remove() {
    echo 'Removing Crafty User'
    userdel crafty
}