summarylogtreecommitdiffstats
path: root/bash-it.install
blob: 83e8353c5ec5aeedd7e99497296b4d1ff6a34130 (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
post_install() {
        cat <<EOF >> /etc/bash.bashrc

source /etc/profile.d/bashit.sh
EOF
        echo "Successfully installed! You may need to remove the PROMPT configuration from the following files"
        readarray -t homes < <(grep 'bash$' /etc/passwd | awk -F: '{print $6}')
        for home in "${homes[@]}"; do
                [[ -f "$home/.bashrc" ]] && echo -e "\t - $home/.bashrc"
                [[ -f "$home/.bash_profile" ]] && echo -e "\t - $home/.bash_profile"
                [[ -f "$home/.profile" ]] && echo -e "\t - $home/.profile"
        done
}

post_upgrade() {
        if ! grep bashit.sh /etc/bash.bashrc &> /dev/null; then
        cat <<EOF >> /etc/bash.bashrc

source /etc/profile.d/bashit.sh
EOF
        fi
        echo "Successfully upgraded! You may need to remove the PROMPT configuration from the following files"
        readarray -t homes < <(grep 'bash$' /etc/passwd | awk -F: '{print $6}')
        for home in "${homes[@]}"; do
                [[ -f "$home/.bashrc" ]] && echo -e "\t - $home/.bashrc"
                [[ -f "$home/.bash_profile" ]] && echo -e "\t - $home/.bash_profile"
                [[ -f "$home/.profile" ]] && echo -e "\t - $home/.profile"
        done
}

post_remove() {
        sed -i '/bashit/d' /etc/bash.bashrc
        echo "Successfully uninstall! You may need to restore the PROMPT configuration to the following files"
        readarray -t homes < <(grep 'bash$' /etc/passwd | awk -F: '{print $6}')
        for home in "${homes[@]}"; do
                [[ -f "$home/.bashrc" ]] && echo -e "\t - $home/.bashrc"
                [[ -f "$home/.bash_profile" ]] && echo -e "\t - $home/.bash_profile"
                [[ -f "$home/.profile" ]] && echo -e "\t - $home/.profile"
        done
}