Skip to content

Commit

Permalink
feat: debian install hooks
Browse files Browse the repository at this point in the history
Pre install check and creates the movies db folder. Pre remove only show
a warning about movies db folder.
  • Loading branch information
faabiosr committed Oct 21, 2023
1 parent 1cb1215 commit 99eb58e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .goreleaser.yaml
Expand Up @@ -46,6 +46,9 @@ nfpms:
license: MIT
formats:
- deb
scripts:
preinstall: "env/debian/pre-install.sh"
preremove: "env/debian/pre-remove.sh"

checksum:
name_template: '{{ .ProjectName }}_checksums.txt'
Expand Down
33 changes: 33 additions & 0 deletions env/debian/pre-install.sh
@@ -0,0 +1,33 @@
#!/bin/sh

before_install() {
echo "- creating database folder"
mkdir -p /var/lib/movies-db
}

before_update() {
if [ ! -d "/var/lib/movies-db" ]
then
echo "- creating database folder"
mkdir -p /var/lib/movies-db
fi
}


if [ "${1}" = "install" -a -z "${2}" ]
then
before_install
exit 0
fi

if [ "${1}" = "upgrade" -a -n "${2}" ]
then
before_update
exit 0
fi

if echo "${1}" | grep -E -q "(abort|fail)"
then
echo "failed to install before the pre-installation script was run." >&2
exit 1
fi
21 changes: 21 additions & 0 deletions env/debian/pre-remove.sh
@@ -0,0 +1,21 @@
#!/bin/sh

before_remove() {
if [ -d "/var/lib/movies-db" ]
then
echo "- database folder exists and won't be removed"
fi
}


if [ "${1}" = "remove" -a -z "${2}" ]
then
before_remove
exit 0
fi

if echo "${1}" | grep -E -q "(abort|fail)"
then
echo "failed to install before the pre-removal script was run." >&2
exit 1
fi

0 comments on commit 99eb58e

Please sign in to comment.