mirror of
https://github.com/varun-r-mallya/server-scripts.git
synced 2025-12-31 20:16:25 +00:00
35
control/Caddyfile
Normal file
35
control/Caddyfile
Normal file
@ -0,0 +1,35 @@
|
||||
# The Caddyfile is an easy way to configure your Caddy web server.
|
||||
#
|
||||
# Unless the file starts with a global options block, the first
|
||||
# uncommented line is always the address of your site.
|
||||
#
|
||||
# To use your own domain name (with automatic HTTPS), first make
|
||||
# sure your domain's A/AAAA DNS records are properly pointed to
|
||||
# this machine's public IP, then replace ":80" below with your
|
||||
# domain name.
|
||||
|
||||
# :80 {
|
||||
# Set this path to your site's directory.
|
||||
# root * /usr/share/caddy
|
||||
|
||||
# Enable the static file server.
|
||||
# file_server
|
||||
|
||||
# Another common task is to set up a reverse proxy:
|
||||
# reverse_proxy localhost:8080
|
||||
|
||||
# Or serve a PHP site through php-fpm:
|
||||
# php_fastcgi localhost:9000
|
||||
#}
|
||||
|
||||
:43211 {
|
||||
basicauth /* {
|
||||
# caddy hash-password --plaintext yourpassword
|
||||
varun $2a$14$ZY.l3V.ecHUWEO0phmNr9.ieQN15n5uIyrlLx4S4rLRKgm6YoGxGe
|
||||
}
|
||||
reverse_proxy localhost:43210
|
||||
|
||||
}
|
||||
|
||||
# Refer to the Caddy docs for more information:
|
||||
# https://caddyserver.com/docs/caddyfile
|
||||
58
control/brightness.py
Executable file
58
control/brightness.py
Executable file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Detect the backlight device
|
||||
def find_backlight_device():
|
||||
base_path = '/sys/class/backlight'
|
||||
try:
|
||||
devices = os.listdir(base_path)
|
||||
if not devices:
|
||||
print("No backlight device found.")
|
||||
sys.exit(1)
|
||||
return os.path.join(base_path, devices[0])
|
||||
except FileNotFoundError:
|
||||
print("Backlight control not supported on this system.")
|
||||
sys.exit(1)
|
||||
|
||||
def get_brightness_info(dev_path):
|
||||
with open(os.path.join(dev_path, 'max_brightness')) as f:
|
||||
max_brightness = int(f.read().strip())
|
||||
with open(os.path.join(dev_path, 'brightness')) as f:
|
||||
current_brightness = int(f.read().strip())
|
||||
return current_brightness, max_brightness
|
||||
|
||||
def set_brightness(dev_path, value):
|
||||
brightness_path = os.path.join(dev_path, 'brightness')
|
||||
try:
|
||||
with open(brightness_path, 'w') as f:
|
||||
f.write(str(value))
|
||||
except PermissionError:
|
||||
print("Permission denied. Try running as root (sudo).")
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: brightness.py <value|+10|-10>")
|
||||
sys.exit(1)
|
||||
|
||||
dev_path = find_backlight_device()
|
||||
current, max_brightness = get_brightness_info(dev_path)
|
||||
arg = sys.argv[1]
|
||||
|
||||
try:
|
||||
if arg.startswith('+') or arg.startswith('-'):
|
||||
new_brightness = current + int(arg)
|
||||
else:
|
||||
new_brightness = int(arg)
|
||||
|
||||
new_brightness = max(0, min(new_brightness, max_brightness))
|
||||
set_brightness(dev_path, new_brightness)
|
||||
print(f"Brightness set to {new_brightness}/{max_brightness}")
|
||||
except ValueError:
|
||||
print("Invalid brightness value.")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
13
control/containers-up.service
Normal file
13
control/containers-up.service
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Run services.sh to run Docker compose on boot
|
||||
After=network-online.target docker.service
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/home/xeon/control/services.sh
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
24
control/services.sh
Executable file
24
control/services.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# List your service directories here (full paths or relative paths)
|
||||
services=(
|
||||
"/home/xeon/management/monitoring"
|
||||
"/home/xeon/management/seanime"
|
||||
)
|
||||
|
||||
#echo "Reducing brightness"
|
||||
#/home/xeon/control/brightness.py 0
|
||||
|
||||
echo "🚀 Starting selected Docker Compose stacks..."
|
||||
|
||||
for dir in "${services[@]}"; do
|
||||
if [ -d "$dir" ] && [ -f "$dir/docker-compose.yml" ]; then
|
||||
echo "➡️ Starting stack in $dir"
|
||||
(cd "$dir" && docker compose up -d)
|
||||
else
|
||||
echo "⚠️ Skipping $dir — not a valid Docker Compose directory"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✅ All listed stacks processed."
|
||||
|
||||
Reference in New Issue
Block a user