Compare commits
6 Commits
b44e7c4663
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8004daa9f0 | |||
| 95ac54ed54 | |||
| 87deb832bd | |||
| d567af0235 | |||
|
|
e5a01d86b3 | ||
|
|
1858652ff9 |
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Ringo Hoffmann
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# snippets
|
||||
|
||||
A collection of some random scripts I use personally.
|
||||
17
bin/buildx
Executable file
17
bin/buildx
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
target=$(rustc --print target-list | fzf --cycle --header "Select build target:")
|
||||
|
||||
if [ -z "$target" ]; then
|
||||
echo "No target selected. Canceled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
cmd="$1"
|
||||
shift
|
||||
else
|
||||
cmd="build"
|
||||
fi
|
||||
|
||||
cross "$cmd" --target "$target" $@
|
||||
46
minecraft-server/restore-backup.sh
Normal file
46
minecraft-server/restore-backup.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
RCLONE_CONFIG="rclone.conf"
|
||||
RCLONE_TARGET="minecraft:"
|
||||
WORLDS_DIR="spigot/worlds"
|
||||
WORLDS_DIR_BACKUP="$WORLDS_DIR.backup"
|
||||
ARCHIVE_PREFIX="etc/mcserver/worlds"
|
||||
SERVICE_NAME="spigot"
|
||||
|
||||
archive=$(rclone --config "$RCLONE_CONFIG" lsf "$RCLONE_TARGET" | sort --reverse | fzf --cycle)
|
||||
|
||||
if [[ -z $archive ]]; then
|
||||
echo "error: no archive file has been selected!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
target_dir=$(mktemp --directory)
|
||||
target_archive="$target_dir/$archive"
|
||||
|
||||
echo "Downloading archive $archive to $target_archive ..."
|
||||
rclone --config "$RCLONE_CONFIG" copy "$RCLONE_TARGET$archive" "$target_dir" --progress
|
||||
|
||||
if [[ -d $WORLDS_DIR_BACKUP ]]; then
|
||||
echo "Deleting old worlds dir backup ($WORLDS_DIR_BACKUP) ..."
|
||||
rm -rf "$WORLDS_DIR_BACKUP"
|
||||
fi
|
||||
|
||||
echo "Un-zipping archive to $target_dir ..."
|
||||
unzip "$target_archive" -d "$target_dir" 1>/dev/null
|
||||
|
||||
echo "Stopping server ..."
|
||||
docker compose stop "$SERVICE_NAME"
|
||||
|
||||
echo "Backing up worlds dir ($WORLDS_DIR -> $WORLDS_DIR_BACKUP) ..."
|
||||
mv "$WORLDS_DIR" "$WORLDS_DIR_BACKUP"
|
||||
|
||||
echo "Restoring world ($target_dir/$ARCHIVE_PREFIX -> $WORLDS_DIR) ..."
|
||||
mv "$target_dir/$ARCHIVE_PREFIX" "$WORLDS_DIR"
|
||||
|
||||
echo "Re-starting server ..."
|
||||
docker compose start "$SERVICE_NAME"
|
||||
|
||||
echo "Cleaning up ..."
|
||||
rm -rf "$target_dir"
|
||||
41
powershell/elden-ring-lp-backup.ps1
Normal file
41
powershell/elden-ring-lp-backup.ps1
Normal file
@@ -0,0 +1,41 @@
|
||||
# This simple powershell script backups up my elden ring save to a remote git repository on my NAS
|
||||
# by creating a commit and pushing it.
|
||||
# After that, OBS, ER Death Counter as well as Elden Ring is started if not already running.
|
||||
|
||||
$OBS_PATH = "C:\Program Files\obs-studio\bin\64bit\obs64.exe"
|
||||
$ERDC_PATH = "C:\Program Files (x86)\ER Death Counter\ER_DeathCounter.exe"
|
||||
$ER_SAVE_ID = "76561198077851234"
|
||||
$ER_LAUCH_PATH = "steam://rungameid/1245620"
|
||||
$ER_PROCESS_NAME = "eldenring"
|
||||
|
||||
|
||||
function Open-If-Not-Already {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Path,
|
||||
[string]$ProcessName,
|
||||
[string]$WorkingDirectory = (Get-Location).Path
|
||||
)
|
||||
|
||||
if (-not $ProcessName) {
|
||||
$ProcessName = (Get-Item $Path).BaseName
|
||||
}
|
||||
|
||||
if (-not (Get-Process -Name "$ProcessName" -ErrorAction SilentlyContinue)) {
|
||||
Write-Output "Starting $ProcessName ($Path) ..."
|
||||
Start-Process "$Path" -WorkingDirectory "$WorkingDirectory"
|
||||
}
|
||||
else {
|
||||
Write-Output "$ProcessName is already running."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||
|
||||
git -C "${HOME}\AppData\Roaming\EldenRing\${ER_SAVE_ID}" commit --all --message "backup-${timestamp}"
|
||||
git -C "${HOME}\AppData\Roaming\EldenRing\${ER_SAVE_ID}" push origin main
|
||||
|
||||
Open-If-Not-Already -Path "$OBS_PATH" -WorkingDirectory (Get-Item "$OBS_PATH").DirectoryName
|
||||
Open-If-Not-Already -Path "$ERDC_PATH"
|
||||
Open-If-Not-Already -Path "$ER_LAUCH_PATH" -ProcessName "$ER_PROCESS_NAME"
|
||||
Reference in New Issue
Block a user