post_install() {
    getent group jdownloader &>/dev/null || groupadd -r jdownloader >/dev/null
    getent passwd jdownloader &>/dev/null || useradd -r -g jdownloader -d /opt/JDownloader/ -s /bin/false -c jdownloader jdownloader >/dev/null

    if [ -d "/opt/JDownloader/" ]; then
        chown -R jdownloader:jdownloader /opt/JDownloader/
        chmod -R 0775 /opt/JDownloader/
        chmod g+s "/opt/JDownloader"
        setfacl -d -m u::rwx,g::rwx,o::rx "/opt/JDownloader"
    fi

    if [ "$(cat /etc/locale.conf | grep "LANG")" = "LANG=pt_BR.UTF-8" ]
    then
    echo -e "\e[34;1m==>\e[39;1m Verificando navegadores suportados. \e[0m"
    else
    echo -e "\e[34;1m==>\e[39;1m Checking supported browsers. \e[0m"
    fi
    if [ -e "/usr/share/applications/firefox.desktop" ]; then
        if [ "$(cat /etc/locale.conf | grep "LANG")" = "LANG=pt_BR.UTF-8" ]
        then
        echo -e "\e[34;1m==>\e[39;1m Firefox encontrado, baixe a extensão no link abaixo: \e[0m"
        else
        echo -e "\e[34;1m==>\e[39;1m Firefox found, download the extension at the link below: \e[0m"
        fi
    echo -e "\e[34;1m==>\e[39;1m https://addons.mozilla.org/firefox/addon/download-with-jdownloader \e[0m"
    fi
    if [ -e "/usr/share/applications/google-chrome.desktop" ]; then
        if [ "$(cat /etc/locale.conf | grep "LANG")" = "LANG=pt_BR.UTF-8" ]
        then
        echo -e "\e[34;1m==>\e[39;1m Google Chrome encontrado, baixe a extensão no link abaixo: \e[0m"
        else
        echo -e "\e[34;1m==>\e[39;1m Google Chrome found, download the extension at the link below: \e[0m"
        fi
    echo -e "\e[34;1m==>\e[39;1m https://chrome.google.com/webstore/detail/download-with-jdownloader/jfpmbokkdeapjommajdfmmheiiakdlgo \e[0m"
    fi
    if [ -e "/usr/share/applications/opera.desktop" ]; then
        if [ "$(cat /etc/locale.conf | grep "LANG")" = "LANG=pt_BR.UTF-8" ]
        then
        echo -e "\e[34;1m==>\e[39;1m Opera encontrado, baixe a extensão no link abaixo: \e[0m"
        else
        echo -e "\e[34;1m==>\e[39;1m Opera found, download the extension at the link below: \e[0m"
        fi
    echo -e "\e[34;1m==>\e[39;1m https://addons.opera.com/extensions/details/download-with-jdownloader \e[0m"
    fi

    if [ "$(cat /etc/locale.conf | grep "LANG")" = "LANG=pt_BR.UTF-8" ]
    then
    echo -e "\e[34;1m==>\e[39;1m Agora você pode usar o JDownloader. \e[0m"
    else
    echo -e "\e[34;1m==>\e[39;1m You can now use JDownloader. \e[0m"
    fi
}

post_upgrade() {
    post_install
}

post_remove() {
    getent passwd jdownloader &>/dev/null && userdel jdownloader >/dev/null
    getent group jdownloader &>/dev/null && groupdel jdownloader >/dev/null

    rm -Rf /opt/JDownloader

    if [ "$(cat /etc/locale.conf | grep "LANG")" = "LANG=pt_BR.UTF-8" ]
    then
    echo -e "\e[34;1m==>\e[39;1m Lembre-se de remover a extensão JDownloader do seu navegador. \e[0m"
    else
    echo -e "\e[34;1m==>\e[39;1m Remember to remove the JDownloader extension from your browser. \e[0m"
    fi
}
