Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c059bc34d8 | |||
| f2a3552286 | |||
| f491fe517a | |||
| f6c8f4fae6 | |||
| b43ea19e1e | |||
| c6ff40e288 | |||
| 86509e2598 | |||
| adc5498641 |
@@ -6,7 +6,7 @@ CPU_ARCH := $(shell lscpu | grep ^Architecture: | sed "s/^Architecture:[[:space:
|
||||
IMAGE_PREFIX := $(if $(filter armv7%,$(CPU_ARCH)),armv7/)
|
||||
REGISTRY_DOMAIN := git.joeac.net
|
||||
REGISTRY_USER := joeac
|
||||
MODULES := http gemini smtp
|
||||
MODULES := http gemini smtp vaultwarden
|
||||
|
||||
|
||||
#############
|
||||
@@ -38,6 +38,24 @@ $(module)/.env: .env
|
||||
cp .env $(module)/.env
|
||||
endef
|
||||
|
||||
define install_module_rule =
|
||||
.PHONY: install_$(module)
|
||||
install_$(module): ~/.config/rc/init.d/joeac.net ~/.config/rc/init.d/joeac.net.$(module)
|
||||
|
||||
~/.config/rc/init.d/joeac.net.$(module): ~/.config/rc/init.d/joeac.net ~/.config/rc/runlevels/default
|
||||
ln -s $(shell realpath ~/.config/rc/init.d/joeac.net) ~/.config/rc/init.d/joeac.net.$(module)
|
||||
rc-update -U add joeac.net.$(module) default
|
||||
rc-service -U joeac.net.$(module) start
|
||||
endef
|
||||
|
||||
define uninstall_module_rule =
|
||||
.PHONY: uninstall_$(module)
|
||||
uninstall_$(module):
|
||||
rc-service -U joeac.net.$(module) stop
|
||||
rc-update -U del joeac.net.$(module) default
|
||||
rm ~/.config/rc/init.d/joeac.net.$(module)
|
||||
endef
|
||||
|
||||
|
||||
#########
|
||||
# RULES #
|
||||
@@ -55,10 +73,13 @@ login_registry:
|
||||
podman login $(REGISTRY_DOMAIN)
|
||||
|
||||
.PHONY: install
|
||||
install: install_nginx install_service install_crontab next_steps
|
||||
install: install_nginx $(foreach module,$(MODULES),install_$(module)) install_crontab
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall: uninstall_nginx uninstall_service uninstall_crontab
|
||||
uninstall: uninstall_nginx uninstall_joeac.net_service $(foreach module,$(MODULES),uninstall_$(module)) uninstall_crontab
|
||||
|
||||
.PHONY: uninstall_joeac.net_service
|
||||
rm ~/.config/rc/joeac.net
|
||||
|
||||
nginx_src := $(shell find -L nginx -type f)
|
||||
nginx_target := $(addprefix /etc/,$(nginx_src))
|
||||
@@ -92,21 +113,26 @@ else
|
||||
sudo rc-service nginx restart
|
||||
endif
|
||||
|
||||
.PHONY: install_service
|
||||
install_service: ~/.config/rc/init.d/joeac.net
|
||||
$(foreach module,$(MODULES),$(eval $(install_module_rule)))
|
||||
$(foreach module,$(MODULES),$(eval $(uninstall_module_rule)))
|
||||
|
||||
~/.config/rc/init.d/joeac.net: openrc/joeac.net
|
||||
~/.config/rc/init.d/joeac.net: openrc/init.d/joeac.net ~/.config/rc/init.d ~/.config/rc/runlevels/default /etc/init.d/user.$(shell whoami) /etc/conf.d/user.$(shell whoami)
|
||||
rm -f ~/.config/rc/init.d/joeac.net; \
|
||||
mkdir -p ~/.config/rc/init.d; \
|
||||
cp openrc/joeac.net ~/.config/rc/init.d/joeac.net \
|
||||
&& rc-update -U add joeac.net default \
|
||||
&& rc-service -U joeac.net start; \
|
||||
cp openrc/init.d/joeac.net ~/.config/rc/init.d/joeac.net
|
||||
|
||||
.PHONY: uninstall_service
|
||||
uninstall_service:
|
||||
rc-service -U joeac.net stop \
|
||||
&& rc-update -U del joeac.net default \
|
||||
&& rm -f ~/.config/rc/init.d/joeac.net; \
|
||||
~/.config/rc/init.d:
|
||||
mkdir -p ~/.config/rc/init.d
|
||||
|
||||
~/.config/rc/runlevels/default:
|
||||
mkdir -p ~/.config/rc/runlevels/default
|
||||
|
||||
/etc/init.d/user.$(shell whoami):
|
||||
sudo ln -s /etc/init.d/user /etc/init.d/user.$(shell whoami)
|
||||
|
||||
/etc/conf.d/user.$(shell whoami): openrc/conf.d/user.$(shell whoami)
|
||||
sudo cp openrc/conf.d/user.$(shell whoami) /etc/conf.d/user.$(shell whoami)
|
||||
sudo rc-update add user.$(shell whoami) default
|
||||
|
||||
.PHONY: install_crontab
|
||||
install_crontab: /etc/periodic/daily/joeac.net
|
||||
@@ -120,10 +146,6 @@ uninstall_crontab:
|
||||
> crontab.tmp
|
||||
sudo mv crontab.tmp /etc/periodic/daily/joeac.net
|
||||
|
||||
.PHONY: next_steps
|
||||
next_steps:
|
||||
@echo "Make sure that your user's default runlevel is triggered by OpenRC. If this isn't already happening, edit openrc/user-default-runlevel with your username, copy it to /etc/init.d, and add it to the system's default runlevel with \`rc-service add <SERVICE> default\`."
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(foreach module,$(MODULES),$(MAKE) --directory=$(module) clean;)
|
||||
|
||||
+14
@@ -1,6 +1,7 @@
|
||||
services:
|
||||
gemini:
|
||||
image: git.joeac.net/joeac/joeac.net-gemini
|
||||
container_name: joeac.net-gemini
|
||||
build:
|
||||
context: .
|
||||
dockerfile: gemini.Dockerfile
|
||||
@@ -9,6 +10,7 @@ services:
|
||||
|
||||
http:
|
||||
image: git.joeac.net/joeac/joeac.net-http
|
||||
container_name: joeac.net-http
|
||||
build:
|
||||
context: .
|
||||
dockerfile: http.Dockerfile
|
||||
@@ -19,6 +21,7 @@ services:
|
||||
|
||||
smtp:
|
||||
image: git.joeac.net/joeac/joeac.net-smtp
|
||||
container_name: joeac.net-smtp
|
||||
build:
|
||||
context: .
|
||||
dockerfile: smtp.Dockerfile
|
||||
@@ -34,6 +37,17 @@ services:
|
||||
secrets:
|
||||
- remote_smtp_password
|
||||
|
||||
vaultwarden:
|
||||
image: docker.io/vaultwarden/server:latest
|
||||
container_name: joeac.net-vaultwarden
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DOMAIN: "https://pwd.joeac.net"
|
||||
volumes:
|
||||
- ./vaultwarden/vw-data/:/data/
|
||||
ports:
|
||||
- "9000:80"
|
||||
|
||||
secrets:
|
||||
remote_smtp_password:
|
||||
external: true
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/home/broughton/.config/nginx/http.d
|
||||
@@ -0,0 +1,27 @@
|
||||
server {
|
||||
server_name joeac.net;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
}
|
||||
|
||||
listen [::]:443 ssl ipv6only=on; # managed by Certbot
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/joeac.net-0001/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/joeac.net-0001/privkey.pem; # managed by Certbot
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
if ($host = joeac.net) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
server_name joeac.net;
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
server {
|
||||
server_name pwd.joeac.net;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:9000;
|
||||
}
|
||||
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/pwd.joeac.net/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/pwd.joeac.net/privkey.pem; # managed by Certbot
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
if ($host = pwd.joeac.net) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
server_name pwd.joeac.net;
|
||||
listen 80;
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
*
|
||||
!.gitignore
|
||||
!user.example
|
||||
@@ -0,0 +1,3 @@
|
||||
# copy this file to user.<USER> for the user you want to be running joeac.net via OpenRC
|
||||
# add in here any user setup, bearing in mind that OpenRC doesn't use your usual login flow
|
||||
# this may include setting up $HOME and/or $XDG_RUNTIME_DIR
|
||||
@@ -3,10 +3,11 @@
|
||||
# https://gist.github.com/itzwam/2069e935385193207f7e5bea7156e21d
|
||||
# https://github.com/0x17de/dockerservice-openrc
|
||||
|
||||
: ${MODULENAME:=${RC_SVCNAME##*.}}
|
||||
: ${SRCDIR:=/usr/local/lib/joeac.net}
|
||||
DOCKER_COMPOSE_UP_ARGS=${DOCKER_COMPOSE_UP_ARGS-"--no-build --no-recreate --no-deps"}
|
||||
|
||||
[ -z "${SVCNAME}" ] && exit 1
|
||||
[ -z "${MODULENAME}" ] && exit 1
|
||||
: ${COMPOSEFILE:="${SRCDIR}/compose.yml"}
|
||||
: ${MAKEFILE:="${SRCDIR}/Makefile"}
|
||||
COMPOSECMD="/usr/bin/podman-compose"
|
||||
@@ -31,14 +32,14 @@ configtest() {
|
||||
|
||||
start() {
|
||||
configtest || return 1
|
||||
ebegin "Starting ${SVCNAME}"
|
||||
"${COMPOSECMD}" -f "${COMPOSEFILE}" up -d ${DOCKER_COMPOSE_UP_ARGS}
|
||||
ebegin "Starting ${MODULENAME}"
|
||||
"${COMPOSECMD}" -f "${COMPOSEFILE}" up -d ${DOCKER_COMPOSE_UP_ARGS} ${MODULENAME}
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping ${SVCNAME}"
|
||||
"${COMPOSECMD}" -f "${COMPOSEFILE}" down --timeout=5
|
||||
ebegin "Stopping ${MODULENAME}"
|
||||
"${COMPOSECMD}" -f "${COMPOSEFILE}" down --timeout=5 ${MODULENAME}
|
||||
eend $?
|
||||
}
|
||||
|
||||
@@ -46,18 +47,19 @@ status() {
|
||||
pods=0
|
||||
started=0
|
||||
while read pod; do
|
||||
pod_service="$(podman inspect $pod | jq .[0].Config.Labels.[\"com.docker.compose.service\"])"
|
||||
if ! [ "$pod_service" = "\"${MODULENAME}\"" ]; then
|
||||
continue
|
||||
fi
|
||||
pods=$(($pods+1))
|
||||
if podman top $pod &>/dev/null; then
|
||||
einfo "status: [$pod] started"
|
||||
started=$(($started+1))
|
||||
exit 0
|
||||
else
|
||||
einfo "status: [$pod] stopped"
|
||||
exit 3
|
||||
fi
|
||||
done < <("${COMPOSECMD}" -f "${COMPOSEFILE}" ps --quiet)
|
||||
if [ $started -eq $pods ]; then
|
||||
einfo "status: started"
|
||||
else
|
||||
einfo "status: stopped"
|
||||
return 3
|
||||
fi
|
||||
einfo "status: no container found for ${MODULENAME}"
|
||||
exit 3
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/sbin/openrc
|
||||
|
||||
description="start <USER> default runlevel"
|
||||
command="openrc"
|
||||
command_args="-U default"
|
||||
command_user="<USER>"
|
||||
Submodule
+1
Submodule vaultwarden added at 19c0baa183
Reference in New Issue
Block a user