WIP debconf

This commit is contained in:
pitchum 2024-01-14 11:27:41 +00:00
parent 3337e87496
commit d804d339fe
7 changed files with 179 additions and 13 deletions

53
debian/config vendored Normal file
View File

@ -0,0 +1,53 @@
#!/bin/sh
# Source debconf library.
. /usr/share/debconf/confmodule
# Choose a domain name
db_input high mobilizon/domain_name || true
db_go
db_get mobilizon/domain_name
if [ -z "$RET" -o "$RET" = " " ]; then
db_set mobilizon/domain_name "mobilizon.localhost.localdomain"
fi
# TCP port
db_input low mobilizon/listen_port || true
db_go
db_get mobilizon/listen_port
if [ -z "$RET" -o "$RET" = " " ]; then
db_set mobilizon/listen_port "4000"
fi
# DB hostname
db_input high mobilizon/db_host || true
db_go
db_get mobilizon/db_host
if [ -z "$RET" -o "$RET" = " " ]; then
db_set mobilizon/db_host "localhost"
fi
# DB name
db_input medium mobilizon/db_name || true
db_go
db_get mobilizon/db_name
if [ -z "$RET" -o "$RET" = " " ]; then
db_set mobilizon/db_name "mobilizon"
fi
# DB username
db_input high mobilizon/db_username || true
db_go
db_get mobilizon/db_username
if [ -z "$RET" -o "$RET" = " " ]; then
db_set mobilizon/db_username "mobilizon"
fi
## DB userpass
#db_input high mobilizon/db_userpass || true
#db_go
#db_get mobilizon/db_userpass
#if [ -z "$RET" -o "$RET" = " " ]; then
# db_set mobilizon/db_userpass ""
#fi

35
debian/config.exs vendored Normal file
View File

@ -0,0 +1,35 @@
# Mobilizon instance configuration
import Config
config :mobilizon, Mobilizon.Web.Endpoint,
server: true,
url: [host: "__DOMAIN_NAME__"],
http: [
ip: {127,0,0,1},
port: __LISTEN_PORT__
],
secret_key_base: "fGRh4o8C28jkQG7PEWG2heRnbpSaYVaukgHuVvZ2/iWlZYKEG1lhDxuHkvLufJe7"
config :mobilizon, Mobilizon.Web.Auth.Guardian,
secret_key: "wDvmyIypO5NdQ7PNLinJs3oRgTiEhidj1IkPu73lzT37ogMuEJPDgBAC60tKZh1w"
config :mobilizon, :instance,
name: "A Debian-base Mobilizon instance",
description: "Change this to a proper description of your instance",
hostname: "__DOMAIN_NAME__",
registrations_open: false,
demo: false,
allow_relay: true,
federating: true,
email_from: "noreply@__DOMAIN_NAME__",
email_reply_to: "noreply@__DOMAIN_NAME__"
config :mobilizon, Mobilizon.Storage.Repo,
adapter: Ecto.Adapters.Postgres,
username: "__DB_USERNAME__",
password: "__DB_USERPASS__",
database: "__DB_NAME__",
hostname: "__DB_HOST__",
port: "5432",
pool_size: 10

3
debian/dirs vendored Normal file
View File

@ -0,0 +1,3 @@
etc/mobilizon
usr/share/mobilizon
var/lib/mobilizon

2
debian/install vendored Normal file
View File

@ -0,0 +1,2 @@
debian/config.exs etc/mobilizon
_build/prod/rel/mobilizon usr/share

28
debian/mobilizon.service vendored Normal file
View File

@ -0,0 +1,28 @@
[Unit]
Description=Mobilizon Service
After=network.target postgresql.service
[Service]
User=mobilizon
WorkingDirectory=/var/lib/mobilizon
ExecStart=/usr/share/mobilizon/bin/mobilizon start
ExecStop=/usr/share/mobilizon/bin/mobilizon stop
KillMode=process
Restart=on-failure
Environment=MIX_ENV=prod
SyslogIdentifier=mobilizon
; Some security directives.
; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops.
PrivateTmp=true
; Mount /usr, /boot, and /etc as read-only for processes invoked by this service.
ProtectSystem=full
; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi.
PrivateDevices=false
; Ensures that the service process and all its children can never gain new privileges through execve().
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target

34
debian/postinst vendored
View File

@ -5,18 +5,8 @@
set -e
# Summary of how this script can be called:
# * <postinst> 'configure' <most-recently-configured-version>
# * <old-postinst> 'abort-upgrade' <new version>
# * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
# <new-version>
# * <postinst> 'abort-remove'
# * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
# <failed-install-package> <version> 'removing'
# <conflicting-package> <version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package.
# Load debconf
. /usr/share/debconf/confmodule
case "$1" in
configure)
@ -32,7 +22,25 @@ case "$1" in
--group \
mobilizon
fi
# sdf
# Use debconf values to initialize config.exs
db_get mobilizon/domain_name
sed -i "s/__DOMAIN_NAME__/${RET}/" /etc/mobilizon/config.exs
db_get mobilizon/listen_port
sed -i "s/__LISTEN_PORT__/${RET}/" /etc/mobilizon/config.exs
db_get mobilizon/db_host
sed -i "s/__DB_HOST__/${RET}/" /etc/mobilizon/config.exs
db_get mobilizon/db_name
sed -i "s/__DB_NAME__/${RET}/" /etc/mobilizon/config.exs
db_get mobilizon/db_username
sed -i "s/__DB_USERNAME__/${RET}/" /etc/mobilizon/config.exs
db_get mobilizon/db_userpass
sed -i "s/__DB_USERPASS__/${RET}/" /etc/mobilizon/config.exs
;;

37
debian/templates vendored Normal file
View File

@ -0,0 +1,37 @@
Template: mobilizon/domain_name
Type: string
Default: mobilizon.localhost.localdomain
Description: Mobilizon's domain name
Your Mobilizon instance need a domain name.
.
This is the domain name users will have to type in their browser.
Template: mobilizon/listen_port
Type: string
Default: 4000
Description: Mobilizon's TCP port
Which TCP port to listen on.
Template: mobilizon/db_host
Type: string
Default: localhost
Description: Mobilizon's Postgresql database host
Specify where the postgresql database is hosted.
Template: mobilizon/db_name
Type: string
Default: mobilizon
Description: Mobilizon's Postgresql database name
Specify the name of the postgresql database.
Template: mobilizon/db_username
Type: string
Default: mobilizon
Description: Mobilizon's Postgresql database username
Specify the username to connect to the postgresql database.
Template: mobilizon/db_userpass
Type: password
Default:
Description: Mobilizon's Postgresql database user password
Specify the password to connect to the postgresql database.