-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yay - desktop infra done for october
- Loading branch information
adnan wahab
committed
Oct 18, 2024
1 parent
053193f
commit fb01c27
Showing
4 changed files
with
237 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
|
||
# hardcode my parameters to desktop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
{ | ||
email [email protected] | ||
log { | ||
output file /var/log/caddy/caddy.log { | ||
|
@@ -8,29 +8,77 @@ | |
} | ||
level DEBUG | ||
} | ||
|
||
} | ||
|
||
files.hashirama.blog { | ||
root * /home/adnan/Videos | ||
file_server browse | ||
header Access-Control-Allow-Origin * | ||
header Access-Control-Allow-Methods "GET, POST, OPTIONS" | ||
header Access-Control-Allow-Headers "Content-Type" | ||
#respond "hi world" | ||
|
||
root * /home/adnan/derp | ||
file_server browse | ||
header Access-Control-Allow-Origin * | ||
header Access-Control-Allow-Methods "GET, POST, OPTIONS" | ||
header Access-Control-Allow-Headers "Content-Type" | ||
} | ||
|
||
hashirama.blog { | ||
tls { | ||
dns cloudflare {env.CLOUDFLARE_API_TOKEN} | ||
resolvers 1.1.1.1 | ||
} | ||
|
||
header Access-Control-Allow-Origin * | ||
header Access-Control-Allow-Methods "GET, POST, OPTIONS" | ||
header Access-Control-Allow-Headers "Content-Type" | ||
reverse_proxy localhost:8080 | ||
|
||
# Add logging for this site | ||
log { | ||
output file /home/adnan/derp/log/caddy/hashirama.blog.log { | ||
roll_size 10MiB | ||
roll_keep 5 | ||
roll_gzip | ||
} | ||
} | ||
} | ||
|
||
jupyter.hashirama.blog { | ||
tls { | ||
dns cloudflare {env.CLOUDFLARE_API_TOKEN} | ||
resolvers 1.1.1.1 | ||
} | ||
# | ||
# jupyter.hashirama.blog { | ||
# tls { | ||
# dns cloudflare {env.CLOUDFLARE_API_TOKEN} | ||
# resolvers 1.1.1.1 | ||
# } | ||
# #respond "hi world" | ||
# header Access-Control-Allow-Origin * | ||
# header Access-Control-Allow-Methods "GET, POST, OPTIONS" | ||
# header Access-Control-Allow-Headers "Content-Type" | ||
# reverse_proxy localhost:8888 | ||
# } | ||
# llama-tools.com { | ||
# # tls { | ||
# # dns cloudflare {env.CLOUDFLARE_API_TOKEN} | ||
# # resolvers 1.1.1.1 | ||
# # } | ||
# #respond "hi world" | ||
# # header Access-Control-Allow-Origin * | ||
# # header Access-Control-Allow-Methods "GET, POST, OPTIONS" | ||
# # header Access-Control-Allow-Headers "Content-Type" | ||
# # reverse_proxy localhost:8080 | ||
# #reverse_proxy localhost:8080 | ||
# respond "hi world" | ||
# } | ||
# files.hashirama.blog { | ||
# tls { | ||
# dns cloudflare {env.CLOUDFLARE_API_TOKEN} | ||
# resolvers 1.1.1.1 | ||
# } | ||
# respond "hi world" | ||
# } | ||
#respond "hi world" | ||
# header Access-Control-Allow-Origin * | ||
# header Access-Control-Allow-Methods "GET, POST, OPTIONS" | ||
# header Access-Control-Allow-Headers "Content-Type" | ||
# reverse_proxy localhost:8080 | ||
|
||
#respond "hi world" | ||
header Access-Control-Allow-Origin * | ||
header Access-Control-Allow-Methods "GET, POST, OPTIONS" | ||
header Access-Control-Allow-Headers "Content-Type" | ||
reverse_proxy localhost:8888 | ||
} | ||
#reverse_proxy localhost:8080 | ||
# log { | ||
# output file /var/log/caddy/access.log | ||
# level INFO | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,112 @@ | ||
#!/bin/bash | ||
# Display the Caddy service file | ||
#echo "Displaying the Caddy service file..." | ||
# cat /etc/systemd/system/caddy.service | ||
# [Unit] | ||
# Description=Caddy web server | ||
# After=network.target | ||
# [Service] | ||
# Environment=HOME=/home/adnan | ||
# ExecStart=/usr/local/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile | ||
# ExecReload=/usr/local/bin/caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile | ||
# Restart=on-failure | ||
# [Install] | ||
# WantedBy=multi-user.target | ||
# Find the Caddy log file | ||
#curl -I https://hashirama.blog | ||
#curl ifconfig.me | ||
# Function to check if Caddy is running | ||
|
||
# admin dahboard to be public | ||
# Check if the Caddyfile has good syntax | ||
echo "Checking Caddyfile syntax..." | ||
sudo caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile || { | ||
echo "Caddyfile has syntax errors." | ||
exit 1 | ||
} | ||
|
||
sudo caddy reload --config /etc/caddy/Caddyfile | ||
|
||
check_caddy_status() { | ||
if systemctl is-active --quiet caddy; then | ||
echo "Caddy is running." | ||
else | ||
echo "Error: Caddy is not running." | ||
sudo systemctl status caddy | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Check if Caddy is already running before stopping it | ||
if systemctl is-active --quiet caddy; then | ||
echo "Stopping Caddy service..." | ||
sudo systemctl stop caddy | ||
else | ||
echo "Caddy is not running, skipping stop." | ||
fi | ||
|
||
# Reload system daemon (only needed if you changed systemd unit files) | ||
echo "Reloading system daemon (if necessary)..." | ||
sudo systemctl daemon-reload | ||
|
||
# sudo systemctl stop homelab-status-page | ||
# Format Caddyfile | ||
echo "Formatting Caddyfile..." | ||
sudo caddy fmt --overwrite /etc/caddy/Caddyfile || { | ||
echo "Error formatting Caddyfile." | ||
exit 1 | ||
} | ||
|
||
# Start Caddy service | ||
echo "Starting Caddy service..." | ||
sudo systemctl start caddy || { | ||
echo "Error starting Caddy service." | ||
exit 1 | ||
} | ||
|
||
# Check Caddy status | ||
echo "Checking Caddy status..." | ||
check_caddy_status | ||
|
||
# Enable Caddy service to start on boot (if not already enabled) | ||
if systemctl is-enabled --quiet caddy; then | ||
echo "Caddy service already enabled on boot." | ||
else | ||
echo "Enabling Caddy service to start on boot..." | ||
sudo systemctl enable caddy || { | ||
echo "Error enabling Caddy service." | ||
exit 1 | ||
} | ||
fi | ||
|
||
# Reload Caddy configuration (optional, Caddy reloads on start by default) | ||
echo "Reloading Caddy configuration..." | ||
sudo caddy reload --config /etc/caddy/Caddyfile || { | ||
echo "Error reloading Caddy configuration." | ||
exit 1 | ||
} | ||
|
||
# Final status check | ||
echo "Performing final status check..." | ||
check_caddy_status | ||
|
||
|
||
|
||
# sudo systemctl start homelab-status-page | ||
|
||
# sudo systemctl enable homelab-status-page | ||
echo "Checking Caddy logs..." | ||
log_file=$(sudo find /var/log/caddy -name "caddy.log" 2>/dev/null) | ||
|
||
sudo systemctl stop caddy | ||
if [ -n "$log_file" ]; then | ||
echo "Caddy log file found at: $log_file" | ||
# Optionally, you can add a command to display the last few lines of the log | ||
# sudo tail -n 20 "$log_file" | ||
else | ||
echo "Caddy log file not found. Checking journalctl logs..." | ||
sudo journalctl -u caddy -n 50 --no-pager | ||
fi | ||
|
||
sudo systemctl start caddy | ||
echo "Restart process completed." | ||
|
||
sudo systemctl enable caddy | ||
# Display the Caddy service file (if needed for debugging) | ||
# echo "Displaying the Caddy service file..." | ||
# cat /etc/systemd/system/caddy.service | ||
|
||
sudo systemctl status caddy #& sudo systemctl status homelab-status-page | ||
#mamba activate sam | ||
# Log file check: Caddy typically logs via systemd's journal, but you can check for file logs |