main
 1#!/usr/bin/env bash
 2
 3# Wakasu Post-Install Setup Script
 4# Description: Post-installation commands for Fedora setup
 5
 6set -euo pipefail
 7
 8# Color output for better readability
 9readonly RED='\033[0;31m'
10readonly GREEN='\033[0;32m'
11readonly YELLOW='\033[1;33m'
12readonly NC='\033[0m' # No Color
13
14# Logging functions
15log_info() {
16	echo -e "${GREEN}[INFO]${NC} $*"
17}
18
19log_warn() {
20	echo -e "${YELLOW}[WARN]${NC} $*"
21}
22
23log_error() {
24	echo -e "${RED}[ERROR]${NC} $*" >&2
25}
26
27setup.syncthing() {
28	log_info "Install syncthing..."
29	sudo dnf install -y syncthing
30
31	log_info "Enable syncthing user service..."
32	systemctl --user enable syncthing.service
33	systemctl --user start syncthing.service
34}
35
36setup.wireguard() {
37	log_info "Install wireguard..."
38	sudo dnf install -y wireguard-tools
39
40	log_info "Setup wireguard configuration..."
41	if [ -z "${WG_PRIVATE_KEY:-}" ]; then
42		log_warn "WG_PRIVATE_KEY not set, skipping wireguard configuration"
43		log_warn "Set WG_PRIVATE_KEY environment variable and re-run to configure"
44		return 0
45	fi
46
47	sudo tee /etc/wireguard/wg0.conf <<EOF
48[Interface]
49PrivateKey = ${WG_PRIVATE_KEY}
50## Client IP
51Address = 10.100.0.90/24
52
53## if you have DNS server running
54# DNS = 192.168.11.1
55
56[Peer]
57PublicKey = +H3fxErP9HoFUrPgU19ra9+GDLQw+VwvLWx3lMct7QI=
58
59## to pass internet trafic 0.0.0.0 but for peer connection only use 192.168.11.0/24, or you can also specify comma separated IPs
60AllowedIPs =  10.100.0.0/24
61
62Endpoint = 167.99.17.238:51820
63PersistentKeepalive = 25
64EOF
65
66	log_info "Wireguard configuration created at /etc/wireguard/wg0.conf"
67}
68
69setup.default_packages() {
70	log_info "Install default packages..."
71	sudo dnf install -y helix acpi
72}
73
74# Main setup function
75main() {
76	log_info "Starting Wakasu post-install setup..."
77
78	setup.default_packages
79	setup.syncthing
80	setup.wireguard
81
82	log_info "Post-install setup completed successfully!"
83}
84
85# Run main function
86main "$@"