Debian Codegraph @

debian/miniflux.postinst

raw
1 #!/bin/sh
2
3 set -e
4
5 . /usr/share/debconf/confmodule
6 . /usr/share/dbconfig-common/dpkg/postinst.pgsql
7
8 dbc_go miniflux "$@"
9
10 create_config() {
11 newcfg="$(mktemp)"
12
13 case "$dbc_dbtype" in
14 pgsql)
15 echo "DATABASE_URL=postgresql://$dbc_dbuser:$dbc_dbpass@$dbc_dbserver/$dbc_dbname" > $newcfg
16 ;;
17 "")
18 ;;
19 esac
20
21 MINIFLUX_USER="miniflux"
22 MINIFLUX_GROUP="$MINIFLUX_USER"
23 MINIFLUX_NAME="minimalist and opinionated feed reader"
24
25 if ! getent group | grep -q "^$MINIFLUX_GROUP:" ; then
26 addgroup --quiet --system "$MINIFLUX_GROUP" 2>/dev/null || true
27 fi
28 if ! getent passwd | grep -q "^$MINIFLUX_USER:" ; then
29 adduser --quiet --system --ingroup "$MINIFLUX_GROUP" \
30 --no-create-home --home /nonexistent \
31 --disabled-password "$MINIFLUX_USER" 2>/dev/null || true
32 fi
33 usermod -c "$MINIFLUX_NAME" -g "$MINIFLUX_GROUP" "$MINIFLUX_USER"
34
35 mkdir -p /etc/miniflux
36 ucf --three-way --debconf-ok "$newcfg" /etc/miniflux/miniflux.conf
37 ucfr miniflux /etc/miniflux/miniflux.conf
38
39 if ! dpkg-statoverride --list /etc/miniflux >/dev/null; then
40 chown "$MINIFLUX_USER:$MINIFLUX_GROUP" /etc/miniflux
41 chown "$MINIFLUX_USER:$MINIFLUX_GROUP" /etc/miniflux/miniflux.conf
42 chmod 644 /etc/miniflux/miniflux.conf
43 fi
44
45 rm -f $newcfg
46
47 miniflux -c "/etc/miniflux/miniflux.conf" -migrate || true
48 }
49
50 if [ "$1" = "configure" ]; then
51 create_config
52 fi
53
54 #DEBHELPER#