feat: ayaka supremacy
This commit is contained in:
93
apps/nginx/module-installer.py
Normal file
93
apps/nginx/module-installer.py
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Compatibility with Angie
|
||||
exec_name = "nginx"
|
||||
|
||||
|
||||
def get_nginx_info() -> tuple[str | None, str | None]:
|
||||
try:
|
||||
output = subprocess.check_output(
|
||||
[exec_name, "-V"], stderr=subprocess.STDOUT
|
||||
).decode("utf-8")
|
||||
version: str | None = None
|
||||
module_path: str | None = None
|
||||
for line in output.splitlines():
|
||||
if line.startswith(f"{exec_name} version:"):
|
||||
# Output is: nginx version: nginx/1.24.0 (Ubuntu)
|
||||
version = line.split("/")[1].split(" ")[0].strip()
|
||||
elif "--modules-path=" in line:
|
||||
# Output is: configure arguments: ... --modules-path=/usr/lib/nginx/modules ...
|
||||
module_path = line.split("--modules-path=")[1].split(" ")[0].strip()
|
||||
if version and module_path:
|
||||
print(f"Nginx version: {version}")
|
||||
print(f"Nginx modules path: {module_path}")
|
||||
return version, module_path
|
||||
except Exception as e:
|
||||
print(f"Error getting Nginx version: {e}")
|
||||
return (None, None)
|
||||
|
||||
|
||||
def download_and_unpack(url: str) -> str:
|
||||
print(f"Downloading '{url}'...")
|
||||
file_name = url.split("/")[-1]
|
||||
subprocess.call(["wget", url])
|
||||
print("Unpacking...")
|
||||
subprocess.call(["tar", "zxvf", file_name])
|
||||
file_name_without_ext = file_name.rsplit(".", 2)[0] # Remove .tar.gz
|
||||
print(f"Download and unpack complete: {file_name} to {file_name_without_ext}")
|
||||
return file_name_without_ext
|
||||
|
||||
|
||||
def main():
|
||||
config_file = "ngx_modules.json"
|
||||
for arg in sys.argv[1:]:
|
||||
if arg.startswith("--config="):
|
||||
config_file = arg.split("--config=")[1]
|
||||
elif arg == "--angie":
|
||||
print("Angie compatibility mode enabled")
|
||||
global exec_name
|
||||
exec_name = "angie"
|
||||
print(f"Using config file: {config_file}")
|
||||
config = json.load(open(config_file))
|
||||
version, module_path = get_nginx_info()
|
||||
if not version or not module_path:
|
||||
print("Could not determine Nginx version or modules path. Exiting.")
|
||||
return
|
||||
source_dir = None
|
||||
nginx_url = None
|
||||
if exec_name == "nginx":
|
||||
nginx_url = f"http://nginx.org/download/nginx-{version}.tar.gz"
|
||||
elif exec_name == "angie":
|
||||
nginx_url = ""
|
||||
else:
|
||||
print(f"Unknown executable name: {exec_name}. Exiting.")
|
||||
return
|
||||
print("Downloading and unpacking Nginx source code...")
|
||||
source_dir = download_and_unpack(nginx_url)
|
||||
module_source_dirs = []
|
||||
for module in config["modules"]:
|
||||
print(f"Downloading module: {module['name']}")
|
||||
module_source_dir = download_and_unpack(module["url"])
|
||||
print(f"Module '{module['name']}' downloaded successfully.")
|
||||
module_source_dirs.append(module_source_dir)
|
||||
# Configure and build modules
|
||||
args = [f"--add-dynamic-module=../{dir}" for dir in module_source_dirs]
|
||||
print("Configuring and building modules...")
|
||||
subprocess.call(["./configure", "--with-compat", *args], cwd=source_dir)
|
||||
subprocess.call(["make", "modules"], cwd=source_dir)
|
||||
# Copy .so files to module path
|
||||
for module in config["modules"]:
|
||||
module_name = module["name"]
|
||||
so_file = f"{module_name}.so"
|
||||
source_so_path = f"{source_dir}/objs/{so_file}"
|
||||
dest_so_path = f"{module_path}/{so_file}"
|
||||
print(f"Copying {source_so_path} to {dest_so_path}...")
|
||||
subprocess.call(["cp", source_so_path, dest_so_path])
|
||||
print("All modules installed successfully.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
19
os/linux/backup.sh
Normal file
19
os/linux/backup.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Check if current user is root
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p /mnt/backup
|
||||
cd /mnt/backup
|
||||
current_date=$(date +%F)
|
||||
# Backup
|
||||
echo "Creating backup of @root subvolume..."
|
||||
btrfs subvolume snapshot -r @root @root_backup_$current_date
|
||||
|
||||
# Remove backups older than 7 days
|
||||
echo "Removing backups older than 7 days..."
|
||||
find /mnt/backup -maxdepth 1 -type d -name '@root_backup_*' -mtime +7 -exec "echo 'Removing {}' && btrfs subvolume delete {}" \;
|
||||
echo "Backup completed successfully."
|
||||
10
web/tiktok/img_story_downloader.js
Normal file
10
web/tiktok/img_story_downloader.js
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
let allImages = document.querySelectorAll("img");
|
||||
let lastImgUrl = "";
|
||||
for (const img of allImages) {
|
||||
if (img.className.includes("ImgPhotoSlide")) {
|
||||
lastImgUrl = img.src;
|
||||
}
|
||||
}
|
||||
window.open(lastImgUrl, '_blank').focus();
|
||||
}
|
||||
1
web/tiktok/video_story_downloader.js
Normal file
1
web/tiktok/video_story_downloader.js
Normal file
@@ -0,0 +1 @@
|
||||
window.open(document.querySelector("video").currentSrc, '_blank').focus();
|
||||
Reference in New Issue
Block a user