post_install() {
    # Chrome and Chromium uses the manifest file in the /etc dir, which is
    # checked as an error in Litium package verification.
    # Thus we are going to move the manifest file after installation.

    # ensure that chrome and chromium extension manifest dir exists
    CHROME_MANIFEST_DIR=/etc/opt/chrome/native-messaging-hosts/
    CHROMIUM_MANIFEST_DIR=/etc/chromium/native-messaging-hosts/
    EDGE_MANIFEST_DIR=/etc/opt/edge/native-messaging-hosts/
    mkdir -p $CHROME_MANIFEST_DIR
    mkdir -p $CHROMIUM_MANIFEST_DIR
    mkdir -p $EDGE_MANIFEST_DIR

    # copy manifest to respective dirs
    cp /opt/softplan-websigner/manifest.json "$CHROME_MANIFEST_DIR"br.com.softplan.webpki.json
    cp /opt/softplan-websigner/manifest.json "$CHROMIUM_MANIFEST_DIR"br.com.softplan.webpki.json
    cp /opt/softplan-websigner/manifest.json "$EDGE_MANIFEST_DIR"br.com.softplan.webpki.json
}

post_upgrade() {
    post_install
}

post_remove() {
    # remove chromium and chrome manifests
    CHROME_MANIFEST_DIR=/etc/opt/chrome/native-messaging-hosts/
    CHROMIUM_MANIFEST_DIR=/etc/chromium/native-messaging-hosts/
    EDGE_MANIFEST_DIR=/etc/opt/edge/native-messaging-hosts/
    rm -rf "$CHROME_MANIFEST_DIR"br.com.softplan.webpki.json
    rm -rf "$CHROMIUM_MANIFEST_DIR"br.com.softplan.webpki.json
    rm -rf "$EDGE_MANIFEST_DIR"br.com.softplan.webpki.json
}
