Skip to content

Instantly share code, notes, and snippets.

View arsalanses's full-sized avatar
🧠
lets play chess

Arsalan Sefidgar arsalanses

🧠
lets play chess
View GitHub Profile
@arsalanses
arsalanses / main.py
Created February 1, 2023 19:12
telegram bot for checking docker health
import telegram
import subprocess
bot = telegram.Bot(token='YOUR_BOT_TOKEN')
chat_id = 'YOUR_CHAT_ID'
def check_docker_health(container_name):
try:
output = subprocess.check_output(["docker", "inspect", "-f", "{{json .State.Health.Status}}", container_name])
if "healthy" in output:
@arsalanses
arsalanses / health-check.sh
Created February 1, 2023 20:08
Check the container's health status
#!/bin/bash
# Check if the Docker container is running
if [ "$(docker inspect -f '{{.State.Running}}' container_name)" = "true" ]; then
echo "Docker container is running."
else
echo "Docker container is not running."
exit 1
fi
#cloud-config
packages:
- certbot
package_update: true
package_upgrade: true
runcmd:
- mkdir xui && cd xui && wget https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh
- certbot certonly --standalone -d change-this-domain.com --register-unsafely-without-email --non-interactive --agree-tos
- cp -r /etc/letsencrypt/live/ ~/certs/
- echo "(!)Reboot server"
@arsalanses
arsalanses / mysql-dump-all-databases.sh
Created March 5, 2023 13:09
mysql-dump-all-databases.sh
#!/usr/bin/env bash
set -x
backup_dir="/mnt/storage/backups/serverdb"
db_backup="/mnt/storage/backups/serverdb/dumps-$(date -I)"
db_user="root"
hostname=$(hostname)
mkdir -p "$db_backup"
#!/bin/bash
#
# Key things to remember, no spaces in pathnames, and try to use full paths (beginning with / )
#
# now fill in these few variables for me
# change to use
# FTP username and Pass
@arsalanses
arsalanses / notify.sh
Last active July 26, 2023 10:47
Set Up GitLab Notifications in Telegram
#!/bin/bash
# You may want to change this
# Or make a secret variable
TELEGRAM_BOT_TOKEN=""
TELEGRAM_CHAT_ID=""
TIME="10"
URL="https://api.telegram.org/bot$${TELEGRAM_BOT_TOKEN}/sendMessage"
GITLAB_USER_NAME=$(echo $GITLAB_USER_NAME | sed 's/ /%20/g')
@arsalanses
arsalanses / notify.sh
Created July 30, 2023 11:03
RocketChat notify bot
#!/bin/bash
TIME="10"
TEXT="Deploy status: $${1}\nProject: $CI_PROJECT_NAME\nURL: $CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID/\nBranch: $CI_COMMIT_REF_SLUG\nUser: $${GITLAB_USER_NAME}"
curl -s -X POST --max-time $${TIME} \
-H "X-Auth-Token: Token" \
-H "X-User-Id: Id" \
-H "Content-type:application/json" \
https://example.org/api/v1/chat.postMessage \
@arsalanses
arsalanses / docker-compose.yml
Created September 25, 2023 13:00
thelounge
services:
traefik:
image: traefik:v2.10.4
restart: unless-stopped
command:
- "--serverstransport.insecureskipverify=true"
- "--log.level=ERROR"
- "--accesslog=true"
@arsalanses
arsalanses / compose.override.yaml
Created October 4, 2023 07:41
Traefik with multiple projects
services:
web:
labels:
- "traefik.http.routers.proj.rule=Host(`proj.traefik.me`)"
- "traefik.http.services.proj.loadbalancer.server.port=8000"
- "traefik.docker.network=traefik"
networks:
- default
- traefik
@arsalanses
arsalanses / docker-compose.yml
Last active October 16, 2023 06:24
An easy to set up and use SSH honeypot, a fake SSH server that lets anyone in and logs their activity
services:
sshesame:
image: ghcr.io/jaksi/sshesame
ports:
- "0.0.0.0:22:2022"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "5"