summarylogtreecommitdiffstats
path: root/crowdsec.install
blob: 9f3493111921b6138393b480a78578a70462bea1 (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
post_install() {
    source /usr/share/crowdsec/wizard.sh -n
    SILENT=true detect_services
    SILENT=true TMP_ACQUIS_FILE_SKIP=skip genacquisition

    cscli capi register --error
    cscli machines add --auto --force --error
    cscli hub update

    CSCLI_BIN_INSTALLED="/usr/bin/cscli" SILENT=true install_collection
}

pre_upgrade() {
    MAJOR=$(echo "$2" | awk -F '.' '{print $1}')
    MINOR=$(echo "$2" | awk -F '.' '{print $2}')

    if [ "${MAJOR}" == 1 ] && [ "${MINOR}" -lt 6 ]; then
        echo "Due to significant changes in the package structure, it is strongly advised not"
        echo "to upgrade from any version older than 1.6.0 to a newer version, as this may lead"
        echo "to potential issues. To safely upgrade to the new version, it is recommended to"
        echo "uninstall the old package and perform a clean installation of the new one."
        echo "Additionally, it is recommended to inspect the /usr/local directory and"
        echo "remove all related files to Crowdsec to ensure a clean installation."
    fi

    cscli config backup /var/lib/crowdsec/backup
}

post_upgrade() {
    if [ -d /var/lib/crowdsec/backup ]; then
        cscli config restore /var/lib/crowdsec/backup && rm -rf /var/lib/crowdsec/backup
    fi
    cscli hub update
    cscli hub upgrade
}

pre_remove() {
    cscli dashboard remove --force --yes --error || true
}