feat: Update scripts
This commit is contained in:
parent
c6f72095cb
commit
c4f9a98658
4
dockerstart.sh
Executable file
4
dockerstart.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo systemctl start docker
|
||||||
|
sudo systemctl start docker.socket
|
4
dockerstop.sh
Executable file
4
dockerstop.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo systemctl stop docker
|
||||||
|
sudo systemctl stop docker.socket
|
119
hsd-domains.py
Normal file
119
hsd-domains.py
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
import getpass
|
||||||
|
|
||||||
|
# Try to get HSD_API_KEY from environment variable
|
||||||
|
HSD_API_KEY = os.environ.get("HSD_API_KEY")
|
||||||
|
if HSD_API_KEY is None:
|
||||||
|
raise Exception("Please set HSD_API_KEY environment variable")
|
||||||
|
|
||||||
|
days_until_expire = 180
|
||||||
|
|
||||||
|
wallet_list = ["cold","hot","registry","greg","hnsau","renewservice"]
|
||||||
|
|
||||||
|
def get_domains(key,wallet):
|
||||||
|
url = f"http://x:{key}@127.0.0.1:12039/wallet/{wallet}/name?own=true"
|
||||||
|
response = requests.get(url)
|
||||||
|
if response.status_code != 200:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# Check if the response is valid JSON
|
||||||
|
try:
|
||||||
|
response.json()
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
return []
|
||||||
|
|
||||||
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
|
def domains_expiring_soon(key,wallet,silent=False):
|
||||||
|
domains = get_domains(key,wallet)
|
||||||
|
expiring = []
|
||||||
|
for domain in domains:
|
||||||
|
days_left = domain["stats"]["daysUntilExpire"]
|
||||||
|
if days_left < days_until_expire:
|
||||||
|
if not silent:
|
||||||
|
print(f"{domain['name']} expires in {days_left} days")
|
||||||
|
expiring.append(domain["name"])
|
||||||
|
|
||||||
|
if len(expiring) > 0:
|
||||||
|
with open(f"/tmp/domains_expiring_soon_{wallet}.txt", "w") as f:
|
||||||
|
for domain in expiring:
|
||||||
|
f.write(f"{domain}\n")
|
||||||
|
return expiring
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# optional args --wallet <wallet> --days <days> --api_key <api_key>
|
||||||
|
parser = argparse.ArgumentParser(description='Check HSD domains for expiration')
|
||||||
|
parser.add_argument('--wallet', help='Wallet to check', default="all")
|
||||||
|
parser.add_argument('--days', help='Days until expiration', default=180)
|
||||||
|
parser.add_argument('--api_key', help='API key', default=HSD_API_KEY)
|
||||||
|
parser.add_argument('--renew', help='Renew domains', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HSD_API_KEY = args.api_key
|
||||||
|
days_until_expire = args.days
|
||||||
|
# Try to convert days_until_expire to an integer
|
||||||
|
try:
|
||||||
|
days_until_expire = int(days_until_expire)
|
||||||
|
except ValueError:
|
||||||
|
print("Invalid days_until_expire value")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
wallets = args.wallet
|
||||||
|
if wallets == "all":
|
||||||
|
wallets = wallet_list
|
||||||
|
else:
|
||||||
|
wallets = [wallets]
|
||||||
|
|
||||||
|
for wallet in wallets:
|
||||||
|
print(f"Checking {wallet} wallet...")
|
||||||
|
domains_expiring_soon(HSD_API_KEY,wallet)
|
||||||
|
|
||||||
|
if args.renew:
|
||||||
|
print("Renewing domains...")
|
||||||
|
for wallet in wallets:
|
||||||
|
domains = domains_expiring_soon(HSD_API_KEY,wallet,silent=True)
|
||||||
|
if len(domains) > 0:
|
||||||
|
print(f"Renewing {len(domains)} domains for {wallet} wallet...")
|
||||||
|
batch = []
|
||||||
|
for domain in domains:
|
||||||
|
batch.append(f'["RENEW", "{domain}"]')
|
||||||
|
|
||||||
|
batchTX = "[" + ", ".join(batch) + "]"
|
||||||
|
reqcontent = f'{{"method": "sendbatch","params":[ {batchTX} ]}}'
|
||||||
|
|
||||||
|
# Select wallet
|
||||||
|
response = requests.post(f'http://x:{HSD_API_KEY}@127.0.0.1:12039', data='{"method": "selectwallet","params": [ "'+wallet+'" ]}')
|
||||||
|
if response.status_code != 200:
|
||||||
|
print(f"Error selecting wallet {wallet}: {response.text}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Ask user for password
|
||||||
|
password = getpass.getpass(prompt=f"Enter password for wallet {wallet}: ")
|
||||||
|
if password != "":
|
||||||
|
response = requests.post(f'http://x:{HSD_API_KEY}@127.0.0.1:12039', data='{"method": "walletpassphrase","params": [ "'+password+'", 300 ]}')
|
||||||
|
if response.status_code != 200:
|
||||||
|
print(f"Error setting password for wallet {wallet}: {response.text}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
response = requests.post(f'http://x:{HSD_API_KEY}@127.0.0.1:12039', data=reqcontent)
|
||||||
|
|
||||||
|
if response.status_code != 200:
|
||||||
|
print(f"Error renewing domains for wallet {wallet}: {response.text}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
output = response.json()
|
||||||
|
if "error" in output:
|
||||||
|
if output["error"]:
|
||||||
|
print(f"Error renewing domains for wallet {wallet}: {output['error']}")
|
||||||
|
|
||||||
|
print("TX: " + output["result"]["hash"])
|
||||||
|
|
||||||
|
|
25
music.sh
25
music.sh
@ -44,10 +44,14 @@ if ! command -v playerctl &>/dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get all player names and statuses
|
# Get all player names and statuses
|
||||||
players=$(playerctl -a -l)
|
players=$(playerctl -a -l 2>/dev/null)
|
||||||
active_players=()
|
active_players=()
|
||||||
brave=""
|
brave=""
|
||||||
|
|
||||||
|
exlude=(
|
||||||
|
"Messenger"
|
||||||
|
)
|
||||||
|
|
||||||
# Loop through each player and check its status
|
# Loop through each player and check its status
|
||||||
for player in $players; do
|
for player in $players; do
|
||||||
if [ "$verbose" -eq 1 ]; then
|
if [ "$verbose" -eq 1 ]; then
|
||||||
@ -62,6 +66,23 @@ for player in $players; do
|
|||||||
brave=$player
|
brave=$player
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
title=$(playerctl -p "$player" metadata --format '{{title}}' 2>/dev/null)
|
||||||
|
if [ "$verbose" -eq 1 ]; then
|
||||||
|
echo "Title: $title"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If title contains any string in the exclude array, skip the player
|
||||||
|
|
||||||
|
for exclude in "${exlude[@]}"; do
|
||||||
|
if [[ "$title" == *"$exclude"* ]]; then
|
||||||
|
if [ "$verbose" -eq 1 ]; then
|
||||||
|
echo "Excluding player $player"
|
||||||
|
fi
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
if [[ "$status" == "Playing" || "$status" == "Paused" ]]; then
|
if [[ "$status" == "Playing" || "$status" == "Paused" ]]; then
|
||||||
if [[ $verbose -eq 1 ]]; then
|
if [[ $verbose -eq 1 ]]; then
|
||||||
echo "Player $player is active"
|
echo "Player $player is active"
|
||||||
@ -195,6 +216,7 @@ elif [ "$active_count" -gt 1 ]; then
|
|||||||
else
|
else
|
||||||
# Check if brave is not empty
|
# Check if brave is not empty
|
||||||
if [ -z "$brave" ]; then
|
if [ -z "$brave" ]; then
|
||||||
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -224,6 +246,7 @@ else
|
|||||||
else
|
else
|
||||||
echo " $truncated_title (Paused)"
|
echo " $truncated_title (Paused)"
|
||||||
fi
|
fi
|
||||||
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
35
venv.sh
35
venv.sh
@ -1,15 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script is used to create a virtual environment for the project
|
# This script is used to create a virtual environment for the project
|
||||||
|
if [ "$1" = "exit" ]; then
|
||||||
# Check if the virtual environment already exists
|
echo "Exiting virtual environment"
|
||||||
if [ -d ".venv" ]; then
|
deactivate
|
||||||
# Check if arg exit passed
|
else
|
||||||
if [ "$1" = "exit" ]; then
|
# Check if the virtual environment already exists
|
||||||
echo "Exiting virtual environment"
|
if [ -d ".venv" ]; then
|
||||||
deactivate
|
|
||||||
else
|
|
||||||
|
|
||||||
# Check if the virtual environment is active
|
# Check if the virtual environment is active
|
||||||
if [ -n "$VIRTUAL_ENV" ]; then
|
if [ -n "$VIRTUAL_ENV" ]; then
|
||||||
echo "Virtual environment is active"
|
echo "Virtual environment is active"
|
||||||
@ -17,17 +14,17 @@ if [ -d ".venv" ]; then
|
|||||||
echo "Activating existing virtual environment"
|
echo "Activating existing virtual environment"
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
fi
|
fi
|
||||||
fi
|
else
|
||||||
else
|
# Create the virtual environment
|
||||||
# Create the virtual environment
|
python3 -m venv .venv
|
||||||
python3 -m venv .venv
|
|
||||||
|
|
||||||
# Activate the virtual environment
|
# Activate the virtual environment
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
|
|
||||||
# Install the required packages
|
# Install the required packages
|
||||||
if [ -f "requirements.txt" ]; then
|
if [ -f "requirements.txt" ]; then
|
||||||
echo "Installing required packages"
|
echo "Installing required packages"
|
||||||
python3 -m pip install -r requirements.txt
|
python3 -m pip install -r requirements.txt
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
39
zellij.sh
39
zellij.sh
@ -1,23 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Save logs to ~/.logs/zellij.log
|
||||||
|
|
||||||
# Check if focus on zellig window worked wmctrl -a zellij
|
# Check if focus on zellig window worked wmctrl -a zellij
|
||||||
if [ -z "$(wmctrl -l | grep Zellij)" ]; then
|
if [ -z "$(wmctrl -l | grep Zellij)" ]; then
|
||||||
echo "No terminal running" > /tmp/message
|
echo "No terminal running" >/tmp/message
|
||||||
|
echo "No terminal running" >>~/.logs/zellij.log
|
||||||
polybar-msg action message hook 0
|
polybar-msg action message hook 0
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
wmctrl -a Zellij
|
wmctrl -a Zellij
|
||||||
|
echo "Focused on terminal" >>~/.logs/zellij.log
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get arguments and run in new zellij pane
|
session=$(zellij list-sessions | grep -v "EXITED" | sed -r 's/\x1B\[[0-9;]*[mK]//g' | awk '{print $1}')
|
||||||
if [ "$#" -ne 0 ];
|
|
||||||
then
|
# For each line in the session list, echo to log
|
||||||
# Check if --cwd flag is passed
|
for line in $session; do
|
||||||
if [ "$1" == "--cwd" ];
|
echo "Found session: $line" >>~/.logs/zellij.log
|
||||||
then
|
echo "Found session: $line"
|
||||||
zellij run -fc --cwd "$2" -- "${@:3}"
|
# Get arguments and run in new zellij pane
|
||||||
|
if [ "$#" -ne 0 ]; then
|
||||||
|
# Check if --cwd flag is passed
|
||||||
|
if [ "$1" == "--cwd" ]; then
|
||||||
|
echo "Using cwd: $2" >>~/.logs/zellij.log
|
||||||
|
echo "Running command: ${@:3}" >>~/.logs/zellij.log
|
||||||
|
|
||||||
|
zellij --session $line run -fc --cwd "$2" -- "${@:3}" >>~/.logs/zellij.log 2>&1
|
||||||
|
else
|
||||||
|
echo "Running command: $@" >>~/.logs/zellij.log
|
||||||
|
zellij --session $line run -fc -- "$@" >>~/.logs/zellij.log 2>&1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
zellij run -fc -- "$@"
|
echo "No command provided" >>~/.logs/zellij.log
|
||||||
|
echo "Usage: zelij.sh <command>"
|
||||||
fi
|
fi
|
||||||
else
|
done
|
||||||
echo "Usage: zelij.sh <command>"
|
|
||||||
fi
|
|
Loading…
Reference in New Issue
Block a user