Add notes and deploy script

This commit is contained in:
2026-03-30 16:59:53 +02:00
parent 601ead1fd9
commit 94817f8cc0
33 changed files with 943 additions and 650 deletions

View File

@@ -0,0 +1,66 @@
---
tags:
- Server
title : Caddy
description : Caddy
date : 2025-01-01
author : Nikola Petrov
---
https://caddyserver.com/docs/
### Install
```
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
```
### Change privilege to access port 80 and 443
```
sudo setcap cap_net_bind_service=+ep $(which caddy)
```
### Caddyfile
/etc/caddy/Caddyfile
```
petrovv.com {
reverse_proxy * 0.0.0.0:4080
}
lang.petrovv.com {
reverse_proxy * 0.0.0.0:8010
}
vault.petrovv.com {
reverse_proxy * 0.0.0.0:6080
}
git.petrovv.com {
reverse_proxy * 0.0.0.0:3000
}
game.petrovv.com {
reverse_proxy * 0.0.0.0:8080
}
rss.petrovv.com {
reverse_proxy * 0.0.0.0:8082
}
files.petrovv.com {
root * /srv
file_server browse
}
```
### comands
```
caddy start
caddy stop
caddy reload
```

View File

@@ -0,0 +1,63 @@
---
tags:
- Server
title : Containers
description : containers on my server
date : 2025-01-01
author : Nikola Petrov
---
## languagetool
```sh
podman pull docker.io/erikvl87/languagetool:latest
podman run --restart=always -d -p 8010:8010 --name languagetool-cont docker.io/erikvl87/languagetool
```
```ini
#/etc/containers/systemd/languagetool.container
[Unit]
Description=LanguageTool Container
After=network.target
[Container]
Image=docker.io/erikvl87/languagetool
Name=languagetool-cont
PublishPort=8010:8010
Environment=Java_Xms=512m
Environment=Java_Xmx=2g
Restart=always
[Install]
WantedBy=default.target
```
## vaultwarden
```sh
podman pull docker.io/vaultwarden/server:latest
podman run -d --restart=always -e SIGNUPS_ALLOWED=false -v /root/vaultwarden/:/data/ -p 6080:80 --name vaultwarden-cont vaultwarden/server:latest
```
```ini
#/etc/containers/systemd/vaultwarden.container
[Unit]
Description=Vaultwarden (Bitwarden-Compatible Server)
After=network.target
[Container]
Image=vaultwarden/server:latest
Name=vaultwarden-cont
PublishPort=6080:80
Volume=/root/vaultwarden/:/data
Environment=SIGNUPS_ALLOWED=false
Restart=always
[Install]
WantedBy=default.target
```
## CALENDAR

View File

@@ -0,0 +1,80 @@
---
tags:
- Server
title : Nginx
description : Nginx
date : 2025-01-01
author : Nikola Petrov
---
### Install
```
sudo apt update
sudo apt install nginx
```
### Test config
```
sudo nginx -t
```
### Config location
```
/etc/nginx
```
### Restart
```
sudo service nginx restart
```
### Template for reverse proxy
```
server{
listen 80;
listen [::]:80;
server_name _;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
```
## For auto ssl/https
- Install snapstore
```
sudo apt update
sudo apt install snapd
```
- remove old certbot
```
sudo apt-get remove certbot
```
- Install certbot
```
sudo snap install --classic certbot
```
- Link command to /usr/bin
```
sudo ln -s /snap/bin/certbot /usr/bin/certbot
```
- Get and install cert
```
sudo certbot --nginx
```
- Test auto renewal
```
sudo certbot renew --dry-run
```

View File

@@ -0,0 +1,20 @@
---
tags:
- Server
title : Commafeed
description : Commafeed
date : 2025-01-01
author : Nikola Petrov
---
https://www.commafeed.com/#/welcome
config
```
commafeed.http-client.max-response-size=10M
commafeed.feed-refresh.max-interval=24H
commafeed.feed-refresh.force-refresh-cooldown-duration=10S
commafeed.database.cleanup.entries-max-age=0
commafeed.database.cleanup.max-feed-capacity=0
```

View File

@@ -0,0 +1,77 @@
---
tags:
- Server
title : Server notes
description : Server notes
date : 2025-01-01
author : Nikola Petrov
---
## To prevent updating of a specific package?
Hold a package:
sudo apt-mark hold <package-name>
Remove the hold:
sudo apt-mark unhold <package-name>
Show all packages on hold:
sudo apt-mark showhold
### USE APT PURGE TO REMOVE APPS
## Dynamic DNS
DDClient [YouTube](https://www.youtube.com/watch?v=iuDCuUEmKF4) [NameCheap](https://www.namecheap.com/support/knowledgebase/article.aspx/583/11/how-do-i-configure-ddclient/)
Install & Setup Instructions:
sudo apt-get install ddclient
sudo nano /etc/ddclient.conf
daemon=3600
ssl=yes
protocol=dyndns2
use=web, web=myip.dnsomatic.com
server=updates.dnsomatic.com
login=Your OpenDNS login
password=Your OpenDNS Password
all.dnsomatic.com
sudo nano /etc/default/ddclient
run_ipup="false"
run_daemon="true"
daemon_interval=3600
To run it initially: sudo ddclient -daemon=0 -debug -verbose -noquiet
## Shutdown
```
systemctl reboot
systemctl poweroff
```
## Raid
https://linuxconfig.org/linux-software-raid-1-setup
## ssh
in `~/.ssh/authorized_keys` paste your pub key
and then disable password login in `/etc/ssh/sshd_config` change `PasswordAuthentication`
to `no`
```
ssh-keygen -t ed25519
systemctl reload sshd
```
## Network monitor tool
`vnstat --help`
## python venv in debian
```sh
sudo apt install -y python3-full python3-pip
python -m venv venv
```

View File

@@ -0,0 +1,132 @@
---
tags:
- Server
title : Systemctl tutorial
description : Systemctl
date : 2025-01-01
author : Nikola Petrov
---
Copy of https://bun.com/docs/guides/ecosystem/systemd
[systemd](https://systemd.io) is an init system and service manager for Linux operating systems that manages the startup and control of system processes and services.
<!-- systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and auto mount points, and implements an elaborate transactional dependency-based service control logic. systemd supports SysV and LSB init scripts and works as a replacement for sysvinit. -->
<!-- Other parts include a logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. -->
---
To run a Bun application as a daemon using **systemd** you'll need to create a _service file_ in `/etc/systemd/system/`.
```sh
$ cd /etc/systemd/system
$ touch my-app.service
```
---
Here is a typical service file that runs an application on system start. You can use this as a template for your own service. Replace `YOUR_USER` with the name of the user you want to run the application as. To run as `root`, replace `YOUR_USER` with `root`, though this is generally not recommended for security reasons.
Refer to the [systemd documentation](https://www.freedesktop.org/software/systemd/man/systemd.service.html) for more information on each setting.
```ini
[Unit]
# describe the app
Description=My App
# start the app after the network is available
After=network.target
[Service]
# usually you'll use 'simple'
# one of https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=
Type=simple
# which user to use when starting the app
User=YOUR_USER
# path to your application's root directory
WorkingDirectory=/home/YOUR_USER/path/to/my-app
# the command to start the app
# requires absolute paths
ExecStart=/home/YOUR_USER/.bun/bin/bun run index.ts
# restart policy
# one of {no|on-success|on-failure|on-abnormal|on-watchdog|on-abort|always}
Restart=always
[Install]
# start the app automatically
WantedBy=multi-user.target
```
---
If your application starts a webserver, note that non-`root` users are not able to listen on ports 80 or 443 by default. To permanently allow Bun to listen on these ports when executed by a non-`root` user, use the following command. This step isn't necessary when running as `root`.
```bash
$ sudo setcap CAP_NET_BIND_SERVICE=+eip ~/.bun/bin/bun
```
---
With the service file configured, you can now _enable_ the service. Once enabled, it will start automatically on reboot. This requires `sudo` permissions.
```bash
$ sudo systemctl enable my-app
```
---
To start the service without rebooting, you can manually _start_ it.
```bash
$ sudo systemctl start my-app
```
---
Check the status of your application with `systemctl status`. If you've started your app successfully, you should see something like this:
```bash
$ sudo systemctl status my-app
● my-app.service - My App
Loaded: loaded (/lib/systemd/system/my-app.service; enabled; preset: enabled)
Active: active (running) since Thu 2023-10-12 11:34:08 UTC; 1h 8min ago
Main PID: 309641 (bun)
Tasks: 3 (limit: 503)
Memory: 40.9M
CPU: 1.093s
CGroup: /system.slice/my-app.service
└─309641 /home/YOUR_USER/.bun/bin/bun run /home/YOUR_USER/application/index.ts
```
---
To update the service, edit the contents of the service file, then reload the daemon.
```bash
sudo systemctl daemon-reload
```
---
For a complete guide on the service unit configuration, you can check [this page](https://www.freedesktop.org/software/systemd/man/systemd.service.html). Or refer to this cheatsheet of common commands:
```bash
$ sudo systemctl daemon-reload # tell systemd that some files got changed
$ sudo systemctl enable my-app # enable the app (to allow auto-start)
$ sudo systemctl disable my-app # disable the app (turns off auto-start)
$ sudo systemctl start my-app # start the app if is stopped
$ sudo systemctl stop my-app # stop the app
$ sudo systemctl restart my-app # restart the app
```
## See logs
https://www.linode.com/docs/guides/how-to-use-journalctl/
https://www.loggly.com/ultimate-guide/using-journalctl/
```
sudo journalctl -u my-app.service
journalctl --vacuum-time=2d // clear
journalctl --since "1 hour ago" -u my-app.service
journalctl -u my-app.service -n 100 // last 100
```

View File

@@ -0,0 +1,8 @@
---
tags:
- Server
title : Server
description : Server notes
date : 2025-01-01
author : Nikola Petrov
---

View File

@@ -0,0 +1,9 @@
---
tags:
- Server
title : Gitea
description : Gitea
date : 2025-01-01
author : Nikola Petrov
---
https://docs.gitea.com/installation/install-from-binary

View File

@@ -0,0 +1,29 @@
---
tags:
- Server
title : Podman
description : Podman
date : 2025-01-01
author : Nikola Petrov
---
https://podman.io/docs/installation
### install
```
sudo apt-get -y install podman
```
https://docs.podman.io/en/latest/
https://github.com/containers/podman/blob/main/docs/tutorials/podman_tutorial.md
sudo podman ps -a
sudo podman container ls
sudo podman ps
sudo podman container rm
sudo podman image ls
sudo podman image rm
https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html