Compare commits
7 Commits
7ff3eb66f8
...
master
Author | SHA1 | Date | |
---|---|---|---|
a7c0018684 | |||
46a517d1f3 | |||
3da28ecb55 | |||
64b1f1e02f | |||
b6f2026113 | |||
807b2f52a5 | |||
6cb1d0e227 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.env
|
||||
__pycache__/
|
||||
|
22
archive/toggle-mozvpn.sh
Normal file
22
archive/toggle-mozvpn.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
STATE=$(mozillavpn status | grep "VPN state" | awk '{print $3}')
|
||||
LOCATION=$(mozillavpn status | grep "Server city" | awk '{print $3}')
|
||||
|
||||
if [ "$STATE" == "off" ]; then
|
||||
FEEDBACK=$(mozillavpn activate)
|
||||
if [[ $FEEDBACK == *"The VPN tunnel is now active"* ]]; then
|
||||
notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Activated: $LOCATION"
|
||||
else
|
||||
notify-send --urgency=critical -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "Error"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$STATE" == "on" ]; then
|
||||
FEEDBACK=$(mozillavpn deactivate)
|
||||
if [[ $FEEDBACK == *"The VPN tunnel is now inactive"* ]]; then
|
||||
notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Deactivated"
|
||||
else
|
||||
notify-send --urgency=critical -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "Error"
|
||||
fi
|
||||
fi
|
2
background.sh
Executable file
2
background.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
DISPLAY=:0 feh --bg-max --randomize /mnt/omv3/picture/YouTube\ Pics/
|
8
catix
Executable file
8
catix
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
if [[ "$1" == "-g" ]]; then
|
||||
GEOMETRY="$2"
|
||||
shift 2
|
||||
fi
|
||||
for f in "$@"; do
|
||||
convert "$f" -geometry ${GEOMETRY:=800x480} sixel:-
|
||||
done
|
21
config-backup.sh
Executable file
21
config-backup.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the paths for the source and destination directories
|
||||
SRC="/home/belar/.config"
|
||||
DST_DIR=/mnt/nas_belar/rsync/config-backup/
|
||||
|
||||
# Sync the source directory to the destination directory
|
||||
/usr/bin/rsync -CERrltm --delete "${SRC}" "${DST_DIR}"
|
||||
|
||||
# Change to the Git repository directory
|
||||
cd $DST_DIR
|
||||
|
||||
# Commit the changes with the current date as the commit message
|
||||
git add .
|
||||
git commit -m "$(date +%Y-%m-%d-%H-%M)"
|
||||
|
||||
# Push the changes to the remote repository if one is configured
|
||||
if [ "$(git remote)" ]; then
|
||||
git push
|
||||
fi
|
||||
|
@ -5,17 +5,9 @@ bluetoothctl connect $(bluetoothctl devices | grep Intuos | awk '{ print $2 }')
|
||||
|
||||
sleep 2
|
||||
|
||||
echo "Setting up single monitor setup.."
|
||||
xinput_out=$(xinput | grep Wacom | awk '{ print $9 }')
|
||||
|
||||
wacoms=$(echo $xinput_out | tr " " "\n")
|
||||
|
||||
wacoms=${wacoms/id=/}
|
||||
wacoms=${wacoms/id=/}
|
||||
|
||||
for w in $wacoms
|
||||
do
|
||||
xinput map-to-output $w DisplayPort-0
|
||||
done
|
||||
xinput map-to-output "Wacom Intuos BT M Pad" DisplayPort-0
|
||||
xinput map-to-output "Wacom Intuos BT M Pen" DisplayPort-0
|
||||
xinput map-to-output "Wacom Intuos BT M Pad pad" DisplayPort-0
|
||||
xinput map-to-output "Wacom Intuos BT M Pen stylus" DisplayPort-0
|
||||
|
||||
echo "done."
|
||||
|
54
dl_image_from_web_with_tag.py
Normal file
54
dl_image_from_web_with_tag.py
Normal file
@ -0,0 +1,54 @@
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
import requests
|
||||
import urllib.request
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
def main():
|
||||
with open('urls.txt', 'r') as file:
|
||||
urls = file.readlines()
|
||||
|
||||
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0'}
|
||||
for url in urls:
|
||||
time.sleep(random.randint(200, 1500) / 1000)
|
||||
url = url.strip() # Remove any leading/trailing whitespace
|
||||
if url:
|
||||
download_image(url, headers)
|
||||
|
||||
|
||||
# Function to process each URL and download the image
|
||||
def download_image(url, headers):
|
||||
try:
|
||||
session = requests.Session()
|
||||
session.headers.update(headers)
|
||||
|
||||
response = session.get(url)
|
||||
session.cookies.update(response.cookies)
|
||||
|
||||
response = session.get(url)
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
player_div = soup.find('div', id='player')
|
||||
|
||||
if player_div:
|
||||
img_tag = player_div.find('img')
|
||||
if img_tag and 'src' in img_tag.attrs:
|
||||
img_url = img_tag['src']
|
||||
img_name = os.path.basename(img_url)
|
||||
img_response = session.get(img_url, headers=headers, cookies=session.cookies)
|
||||
with open(img_name, 'wb') as img_file:
|
||||
img_file.write(img_response.content)
|
||||
|
||||
print(f'Image from {url} downloaded as {img_name}')
|
||||
|
||||
else:
|
||||
print(f'No img tag found inside the player div for {url}.')
|
||||
else:
|
||||
print(f'No div with id "player" found for {url}.')
|
||||
except Exception as e:
|
||||
print(f'Error processing {url}: {e}')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
8
get_fullmoon.py
Normal file
8
get_fullmoon.py
Normal file
@ -0,0 +1,8 @@
|
||||
from fullmoon import NextFullMoon
|
||||
|
||||
|
||||
n = NextFullMoon()
|
||||
|
||||
|
||||
print(n.next_full_moon())
|
||||
|
15
get_weather_data.py
Normal file
15
get_weather_data.py
Normal file
@ -0,0 +1,15 @@
|
||||
import os
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
def main():
|
||||
load_dotenv('.env')
|
||||
apikey = os.environ.get("WEATHER_API_KEY")
|
||||
|
||||
url = f"https://my.meteoblue.com/packages/basic-1h_basic-day?apikey={apikey}&lat=47.517766&lon=8.995523&asl=475&format=json"
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
print(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
BIN
icons/tailscale.png
Normal file
BIN
icons/tailscale.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
1
live-background.sh
Executable file
1
live-background.sh
Executable file
@ -0,0 +1 @@
|
||||
mpv --fs --loop --no-audio ~/.background/live/Cafeshka\ [sRrDXJVjlP8].webm
|
53
minecraft/backup.sh
Executable file
53
minecraft/backup.sh
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR_TO_BACKUP="/opt/Prominence_II"
|
||||
BACKUP_DEST="/opt/backups"
|
||||
|
||||
systemctl is-active --quiet mcserver-prominence2.service
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Service not running."
|
||||
echo "Skipping shutdown procedure."
|
||||
else
|
||||
echo "Notifying players"
|
||||
/opt/mcrcon/mcrcon -p jEPqvH2oWs5v 'say Restarting in 5 minutes for backup...'
|
||||
sleep 300
|
||||
|
||||
/opt/mcrcon/mcrcon -p jEPqvH2oWs5v 'say Restarting in 30 seconds for backup...'
|
||||
sleep 30
|
||||
|
||||
echo "Stopping mc-server-prominence2.service"
|
||||
systemctl stop mcserver-prominence2.service
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Couldn't stop service. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
CURRENT_DATE=$(date +%Y-%m-%d_%H-%M)
|
||||
echo "Creating $BACKUP_DEST/$CURRENT_DATE.tar.gz"
|
||||
tar -czf "$BACKUP_DEST/$CURRENT_DATE.tar.gz" "$DIR_TO_BACKUP"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Couldn't create backup. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Starting mcserver-prominence2.service"
|
||||
systemctl start mcserver-prominence2.service
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Couldn't start service. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Delete old backups if there are more than 10
|
||||
if [ $(ls $BACKUP_DEST/*.tar.gz | wc -l) -gt 10 ]
|
||||
then
|
||||
echo "Files to clean up: "
|
||||
ls -t $BACKUP_DEST/*.tar.gz | tail -n 1
|
||||
ls -t $BACKUP_DEST/*.tar.gz | tail -n 1 | xargs rm
|
||||
fi
|
||||
|
||||
|
||||
echo "Backup successful."
|
BIN
minecraft/cache/mojang_1.21.1.jar
vendored
Normal file
BIN
minecraft/cache/mojang_1.21.1.jar
vendored
Normal file
Binary file not shown.
17
minecraft/mcserver-prominence2.service
Normal file
17
minecraft/mcserver-prominence2.service
Normal file
@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Minecraft Prominence II Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=mcserver
|
||||
Group=mcserver
|
||||
|
||||
SendSIGKILL=no
|
||||
WorkingDirectory=/opt/Prominence_II/
|
||||
ExecStart=/opt/Prominence_II/start.sh
|
||||
ExecStop=/opt/Prominence_II/stop.sh
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
55
minecraft/papermc-backup.sh
Executable file
55
minecraft/papermc-backup.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR_TO_BACKUP="/home/mcserver/mc-papermc-server"
|
||||
BACKUP_DEST="/opt/backups/papermc-server"
|
||||
SERVICE_NAME="mcserver-papermc.service"
|
||||
|
||||
systemctl is-active --quiet $SERVICE_NAME
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Service not running."
|
||||
echo "Skipping shutdown procedure."
|
||||
else
|
||||
echo "Notifying players"
|
||||
/usr/local/bin/mcrcon -H 5.161.249.43 -p 5eXeERr4Tkg6kAxc4U 'say Restarting in 5 minutes for backup...'
|
||||
sleep 300
|
||||
|
||||
/usr/local/bin/mcrcon -H 5.161.249.43 -p 5eXeERr4Tkg6kAxc4U 'say Restarting in 30 seconds for backup...'
|
||||
sleep 30
|
||||
|
||||
echo "Stopping $SERVICE_NAME"
|
||||
systemctl stop $SERVICE_NAME
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Couldn't stop service. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
CURRENT_DATE=$(date +%Y-%m-%d_%H-%M)
|
||||
echo "Creating $BACKUP_DEST/$CURRENT_DATE.tar.gz"
|
||||
tar -czf "$BACKUP_DEST/$CURRENT_DATE.tar.gz" "$DIR_TO_BACKUP"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Couldn't create backup. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Starting $SERVICE_NAME"
|
||||
systemctl start $SERVICE_NAME
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Couldn't start service. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Delete old backups if there are more than 10
|
||||
if [ $(ls $BACKUP_DEST/*.tar.gz | wc -l) -gt 10 ]
|
||||
then
|
||||
echo "Files to clean up: "
|
||||
ls -t $BACKUP_DEST/*.tar.gz | tail -n 1
|
||||
ls -t $BACKUP_DEST/*.tar.gz | tail -n 1 | xargs rm
|
||||
fi
|
||||
|
||||
|
||||
echo "Backup successful."
|
21
minecraft/papermc-start.sh
Normal file
21
minecraft/papermc-start.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
PROJECT="paper"
|
||||
MINECRAFT_VERSION="1.21.1"
|
||||
|
||||
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds | \
|
||||
jq -r '.builds | map(select(.channel == "default") | .build) | .[-1]')
|
||||
|
||||
if [ "$LATEST_BUILD" != "null" ]; then
|
||||
JAR_NAME=${PROJECT}-${MINECRAFT_VERSION}-${LATEST_BUILD}.jar
|
||||
PAPERMC_URL="https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}"
|
||||
|
||||
# Download the latest Paper version
|
||||
curl -o server.jar $PAPERMC_URL
|
||||
echo "Download completed"
|
||||
else
|
||||
echo "No stable build for version $MINECRAFT_VERSION found :("
|
||||
fi
|
||||
|
||||
|
||||
java -Xms6144M -Xmx6144M -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui
|
BIN
minecraft/server.jar
Normal file
BIN
minecraft/server.jar
Normal file
Binary file not shown.
433
minecraft/start.sh
Executable file
433
minecraft/start.sh
Executable file
@ -0,0 +1,433 @@
|
||||
#!/usr/bin/env bash
|
||||
###############################################################################################
|
||||
# Copyright (C) 2024 Griefed
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
# USA
|
||||
#
|
||||
# The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE
|
||||
###############################################################################################
|
||||
#
|
||||
# Start script generated by ServerPackCreator 5.1.19.
|
||||
# The template which was used in the generation of this script can be found at:
|
||||
# https://github.com/Griefed/ServerPackCreator/blob/5.1.19/serverpackcreator-api/src/jvmMain/resources/de/griefed/resources/server_files/default_template.sh
|
||||
#
|
||||
# The Linux scripts are intended to be run using bash (indicated by the `#!/usr/bin/env bash` at the top),
|
||||
# i.e. by simply calling `./start.sh` or `bash start.sh`.
|
||||
# Using any other method may work, but can also lead to unexpected behavior.
|
||||
# Running the Linux scripts on MacOS has been done before, but is not tested by the developers of ServerPackCreator.
|
||||
# Results may wary, no guarantees.
|
||||
#
|
||||
# Depending on which modloader is set, different checks are run to ensure the server will start accordingly.
|
||||
# If the modloader checks and setup are passed, Minecraft and EULA checks are run.
|
||||
# If everything is in order, the server is started.
|
||||
#
|
||||
# Depending on the Minecraft version you will require a different Java version to run the server.
|
||||
# 1.16.5 and older requires Java 8 (Java 11 will run better and work with 99% of mods, give it a try)
|
||||
# Linux:
|
||||
# You may acquire a Java 8 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk8&version=8&package=jre&arch=x64&os=linux
|
||||
# You may acquire a java 11 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk11&version=11&package=jre&arch=x64&os=linux
|
||||
# macOS:
|
||||
# You may acquire a Java 8 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk8&version=8&package=jre&arch=x64&os=mac
|
||||
# You may acquire a java 11 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk11&version=11&package=jre&arch=x64&os=mac
|
||||
# 1.18.2 and newer requires Java 17 (Java 18 will run better and work with 99% of mods, give it a try)
|
||||
# Linux:
|
||||
# You may acquire a Java 17 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk17&version=17&package=jre&arch=x64&os=linux
|
||||
# You may acquire a Java 18 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk18&version=18&package=jre&arch=x64&os=linux
|
||||
# macOS:
|
||||
# You may acquire a Java 17 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk17&version=17&package=jre&arch=x64&os=mac
|
||||
# You may acquire a Java 18 JRE here: https://adoptium.net/temurin/releases/?variant=openjdk18&version=18&package=jre&arch=x64&os=mac
|
||||
|
||||
if [[ "$(id -u)" == "0" ]]; then
|
||||
echo "Warning! Running with administrator-privileges is not recommended."
|
||||
fi
|
||||
|
||||
echo "Start script generated by ServerPackCreator 5.1.19."
|
||||
echo "To change the launch settings of this server, such as JVM args / flags, Minecraft version, modloader version etc., edit the variables.txt-file."
|
||||
|
||||
# Acquire variables from variables.txt
|
||||
source "variables.txt"
|
||||
|
||||
# Variables with do_not_manually_edit are set automatically during script execution,
|
||||
# so manually editing them will have no effect, as they will be overridden.
|
||||
MINECRAFT_SERVER_JAR_LOCATION="do_not_manually_edit"
|
||||
LAUNCHER_JAR_LOCATION="do_not_manually_edit"
|
||||
SERVER_RUN_COMMAND="do_not_manually_edit"
|
||||
|
||||
crash() {
|
||||
echo "Exiting..."
|
||||
read -n 1 -s -r -p "Press any key to continue"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# $1 = Filename to check for
|
||||
# $2 = Filename to save download as
|
||||
# $3 = URL to download $2 from
|
||||
# true if the file was successfully downloaded, false if it already exists
|
||||
downloadIfNotExist() {
|
||||
if [[ ! -s "${1}" ]]; then
|
||||
|
||||
echo "${1} could not be found." >&2
|
||||
echo "Downloading ${2}" >&2
|
||||
echo "from ${3}" >&2
|
||||
curl -# -L -o "./${2}" "${3}"
|
||||
|
||||
if [[ -s "${2}" ]]; then
|
||||
echo "Download complete." >&2
|
||||
echo "true"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "${1} present." >&2
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
runJavaCommand() {
|
||||
"$JAVA" ${1}
|
||||
}
|
||||
|
||||
checkJavaBitness() {
|
||||
"$JAVA" "-version" 2>&1 | grep -i "32-Bit" && echo "WARNING! 32-Bit Java detected! It is highly recommended to use a 64-Bit version of Java!"
|
||||
}
|
||||
|
||||
# If modloader = Forge, run Forge-specific checks
|
||||
setup_forge() {
|
||||
echo ""
|
||||
echo "Running Forge checks and setup..."
|
||||
|
||||
FORGE_INSTALLER_URL="https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}-installer.jar"
|
||||
|
||||
FORGE_JAR_LOCATION="do_not_manually_edit"
|
||||
IFS="." read -ra MINOR <<<"${MINECRAFT_VERSION}"
|
||||
|
||||
if [[ ${MINOR[1]} -le 16 ]]; then
|
||||
FORGE_JAR_LOCATION="forge.jar"
|
||||
LAUNCHER_JAR_LOCATION="forge.jar"
|
||||
MINECRAFT_SERVER_JAR_LOCATION="minecraft_server.${MINECRAFT_VERSION}.jar"
|
||||
SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${JAVA_ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui"
|
||||
else
|
||||
FORGE_JAR_LOCATION="libraries/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}-server.jar"
|
||||
MINECRAFT_SERVER_JAR_LOCATION="libraries/net/minecraft/server/${MINECRAFT_VERSION}/server-${MINECRAFT_VERSION}.jar"
|
||||
SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true @user_jvm_args.txt @libraries/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/unix_args.txt nogui"
|
||||
|
||||
echo "Generating user_jvm_args.txt from variables..."
|
||||
echo "Edit JAVA_ARGS in your variables.txt. Do not edit user_jvm_args.txt directly!"
|
||||
echo "Manually made changes to user_jvm_args.txt will be lost in the nether!"
|
||||
rm -f user_jvm_args.txt
|
||||
{
|
||||
echo "# Xmx and Xms set the maximum and minimum RAM usage, respectively."
|
||||
echo "# They can take any number, followed by an M or a G."
|
||||
echo "# M means Megabyte, G means Gigabyte."
|
||||
echo "# For example, to set the maximum to 3GB: -Xmx3G"
|
||||
echo "# To set the minimum to 2.5GB: -Xms2500M"
|
||||
echo "# A good default for a modded server is 4GB."
|
||||
echo "# Uncomment the next line to set it."
|
||||
echo "# -Xmx4G"
|
||||
echo "${JAVA_ARGS}"
|
||||
} >>user_jvm_args.txt
|
||||
fi
|
||||
|
||||
if [[ $(downloadIfNotExist "${FORGE_JAR_LOCATION}" "forge-installer.jar" "${FORGE_INSTALLER_URL}") == "true" ]]; then
|
||||
|
||||
echo "Forge Installer downloaded. Installing..."
|
||||
runJavaCommand "-jar forge-installer.jar --installServer"
|
||||
|
||||
if [[ ${MINOR[1]} -gt 16 ]]; then
|
||||
rm -f run.bat
|
||||
rm -f run.sh
|
||||
else
|
||||
echo "Renaming forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}.jar to forge.jar"
|
||||
mv forge-"${MINECRAFT_VERSION}"-"${MODLOADER_VERSION}".jar forge.jar
|
||||
mv forge-"${MINECRAFT_VERSION}"-"${MODLOADER_VERSION}-universal".jar forge.jar
|
||||
fi
|
||||
|
||||
if [[ -s "${FORGE_JAR_LOCATION}" ]]; then
|
||||
rm -f forge-installer.jar
|
||||
rm -f forge-installer.jar.log
|
||||
echo "Installation complete. forge-installer.jar deleted."
|
||||
else
|
||||
rm -f forge-installer.jar
|
||||
echo "Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection."
|
||||
crash
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
# If modloader = NeoForge, run NeoForge-specific checks
|
||||
setup_neoforge() {
|
||||
echo ""
|
||||
echo "Running NeoForge checks and setup..."
|
||||
|
||||
FORGE_JAR_LOCATION="libraries/net/neoforged/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}-server.jar"
|
||||
MINECRAFT_SERVER_JAR_LOCATION="libraries/net/minecraft/server/${MINECRAFT_VERSION}/server-${MINECRAFT_VERSION}.jar"
|
||||
SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true @user_jvm_args.txt @libraries/net/neoforged/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/unix_args.txt nogui"
|
||||
|
||||
echo "Generating user_jvm_args.txt from variables..."
|
||||
echo "Edit JAVA_ARGS in your variables.txt. Do not edit user_jvm_args.txt directly!"
|
||||
echo "Manually made changes to user_jvm_args.txt will be lost in the nether!"
|
||||
rm -f user_jvm_args.txt
|
||||
{
|
||||
echo "# Xmx and Xms set the maximum and minimum RAM usage, respectively."
|
||||
echo "# They can take any number, followed by an M or a G."
|
||||
echo "# M means Megabyte, G means Gigabyte."
|
||||
echo "# For example, to set the maximum to 3GB: -Xmx3G"
|
||||
echo "# To set the minimum to 2.5GB: -Xms2500M"
|
||||
echo "# A good default for a modded server is 4GB."
|
||||
echo "# Uncomment the next line to set it."
|
||||
echo "# -Xmx4G"
|
||||
echo "${JAVA_ARGS}"
|
||||
} >>user_jvm_args.txt
|
||||
|
||||
|
||||
if [[ $(downloadIfNotExist "${FORGE_JAR_LOCATION}" "neoforge-installer.jar" "${NEOFORGE_INSTALLER_URL}") == "true" ]]; then
|
||||
|
||||
echo "NeoForge Installer downloaded. Installing..."
|
||||
runJavaCommand "-jar neoforge-installer.jar --installServer"
|
||||
echo "Renaming forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}.jar to forge.jar"
|
||||
mv forge-"${MINECRAFT_VERSION}"-"${MODLOADER_VERSION}".jar forge.jar
|
||||
|
||||
if [[ -s "${FORGE_JAR_LOCATION}" ]]; then
|
||||
rm -f neoforge-installer.jar
|
||||
rm -f neoforge-installer.jar.log
|
||||
echo "Installation complete. neoforge-installer.jar deleted."
|
||||
else
|
||||
rm -f neoforge-installer.jar
|
||||
echo "Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection."
|
||||
crash
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
# If modloader = Fabric, run Fabric-specific checks
|
||||
setup_fabric() {
|
||||
echo ""
|
||||
echo "Running Fabric checks and setup..."
|
||||
|
||||
FABRIC_INSTALLER_URL="https://maven.fabricmc.net/net/fabricmc/fabric-installer/${FABRIC_INSTALLER_VERSION}/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
|
||||
FABRIC_CHECK_URL="https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${MODLOADER_VERSION}/server/json"
|
||||
FABRIC_AVAILABLE="$(curl -LI ${FABRIC_CHECK_URL} -o /dev/null -w '%{http_code}\n' -s)"
|
||||
IMPROVED_FABRIC_LAUNCHER_URL="https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${MODLOADER_VERSION}/${FABRIC_INSTALLER_VERSION}/server/jar"
|
||||
IMPROVED_FABRIC_LAUNCHER_AVAILABLE="$(curl -LI ${IMPROVED_FABRIC_LAUNCHER_URL} -o /dev/null -w '%{http_code}\n' -s)"
|
||||
|
||||
if [[ "$IMPROVED_FABRIC_LAUNCHER_AVAILABLE" == "200" ]]; then
|
||||
echo "Improved Fabric Server Launcher available..."
|
||||
echo "The improved launcher will be used to run this Fabric server."
|
||||
LAUNCHER_JAR_LOCATION="fabric-server-launcher.jar"
|
||||
downloadIfNotExist "fabric-server-launcher.jar" "fabric-server-launcher.jar" "${IMPROVED_FABRIC_LAUNCHER_URL}" >/dev/null
|
||||
elif [[ "${FABRIC_AVAILABLE}" != "200" ]]; then
|
||||
echo "Fabric is not available for Minecraft ${MINECRAFT_VERSION}, Fabric ${MODLOADER_VERSION}."
|
||||
crash
|
||||
elif [[ $(downloadIfNotExist "fabric-server-launch.jar" "fabric-installer.jar" "${FABRIC_INSTALLER_URL}") == "true" ]]; then
|
||||
|
||||
echo "Installer downloaded..."
|
||||
LAUNCHER_JAR_LOCATION="fabric-server-launch.jar"
|
||||
MINECRAFT_SERVER_JAR_LOCATION="server.jar"
|
||||
runJavaCommand "-jar fabric-installer.jar server -mcversion ${MINECRAFT_VERSION} -loader ${MODLOADER_VERSION} -downloadMinecraft"
|
||||
|
||||
if [[ -s "fabric-server-launch.jar" ]]; then
|
||||
rm -rf .fabric-installer
|
||||
rm -f fabric-installer.jar
|
||||
echo "Installation complete. fabric-installer.jar deleted."
|
||||
else
|
||||
rm -f fabric-installer.jar
|
||||
echo "fabric-server-launch.jar not found. Maybe the Fabric servers are having trouble."
|
||||
echo "Please try again in a couple of minutes and check your internet connection."
|
||||
crash
|
||||
fi
|
||||
|
||||
else
|
||||
echo "fabric-server-launch.jar present. Moving on..."
|
||||
LAUNCHER_JAR_LOCATION="fabric-server-launcher.jar"
|
||||
MINECRAFT_SERVER_JAR_LOCATION="server.jar"
|
||||
fi
|
||||
|
||||
SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${JAVA_ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui"
|
||||
}
|
||||
|
||||
# If modloader = Quilt, run Quilt-specific checks
|
||||
setup_quilt() {
|
||||
echo ""
|
||||
echo "Running Quilt checks and setup..."
|
||||
|
||||
QUILT_INSTALLER_URL="https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/${QUILT_INSTALLER_VERSION}/quilt-installer-${QUILT_INSTALLER_VERSION}.jar"
|
||||
QUILT_CHECK_URL="https://meta.fabricmc.net/v2/versions/intermediary/${MINECRAFT_VERSION}"
|
||||
QUILT_AVAILABLE="$(curl -LI ${QUILT_CHECK_URL} -o /dev/null -w '%{http_code}\n' -s)"
|
||||
|
||||
if [[ "${#QUILT_AVAILABLE}" -eq "2" ]]; then
|
||||
echo "Quilt is not available for Minecraft ${MINECRAFT_VERSION}, Quilt ${MODLOADER_VERSION}."
|
||||
crash
|
||||
elif [[ $(downloadIfNotExist "quilt-server-launch.jar" "quilt-installer.jar" "${QUILT_INSTALLER_URL}") == "true" ]]; then
|
||||
echo "Installer downloaded. Installing..."
|
||||
runJavaCommand "-jar quilt-installer.jar install server ${MINECRAFT_VERSION} --download-server --install-dir=."
|
||||
|
||||
if [[ -s "quilt-server-launch.jar" ]]; then
|
||||
rm quilt-installer.jar
|
||||
echo "Installation complete. quilt-installer.jar deleted."
|
||||
else
|
||||
rm -f quilt-installer.jar
|
||||
echo "quilt-server-launch.jar not found. Maybe the Quilt servers are having trouble."
|
||||
echo "Please try again in a couple of minutes and check your internet connection."
|
||||
crash
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
LAUNCHER_JAR_LOCATION="quilt-server-launch.jar"
|
||||
MINECRAFT_SERVER_JAR_LOCATION="server.jar"
|
||||
SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${JAVA_ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui"
|
||||
}
|
||||
|
||||
# If modloader = LegacyFabric, run LegacyFabric-specific checks
|
||||
setup_legacyfabric() {
|
||||
echo ""
|
||||
echo "Running LegacyFabric checks and setup..."
|
||||
|
||||
LEGACYFABRIC_INSTALLER_URL="https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/${LEGACYFABRIC_INSTALLER_VERSION}/fabric-installer-${LEGACYFABRIC_INSTALLER_VERSION}.jar"
|
||||
LEGACYFABRIC_CHECK_URL="https://meta.legacyfabric.net/v2/versions/loader/${MINECRAFT_VERSION}"
|
||||
LEGACYFABRIC_AVAILABLE="$(curl -LI ${LEGACYFABRIC_CHECK_URL} -o /dev/null -w '%{http_code}\n' -s)"
|
||||
|
||||
if [[ "${#LEGACYFABRIC_AVAILABLE}" -eq "2" ]]; then
|
||||
echo "LegacyFabric is not available for Minecraft ${MINECRAFT_VERSION}, LegacyFabric ${MODLOADER_VERSION}."
|
||||
crash
|
||||
elif [[ $(downloadIfNotExist "fabric-server-launch.jar" "legacyfabric-installer.jar" "${LEGACYFABRIC_INSTALLER_URL}") == "true" ]]; then
|
||||
echo "Installer downloaded. Installing..."
|
||||
runJavaCommand "-jar legacyfabric-installer.jar server -mcversion ${MINECRAFT_VERSION} -loader ${MODLOADER_VERSION} -downloadMinecraft"
|
||||
|
||||
if [[ -s "fabric-server-launch.jar" ]]; then
|
||||
rm legacyfabric-installer.jar
|
||||
echo "Installation complete. legacyfabric-installer.jar deleted."
|
||||
else
|
||||
rm -f legacyfabric-installer.jar
|
||||
echo "fabric-server-launch.jar not found. Maybe the LegacyFabric servers are having trouble."
|
||||
echo "Please try again in a couple of minutes and check your internet connection."
|
||||
crash
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
LAUNCHER_JAR_LOCATION="fabric-server-launch.jar"
|
||||
MINECRAFT_SERVER_JAR_LOCATION="server.jar"
|
||||
SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${JAVA_ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui"
|
||||
}
|
||||
|
||||
# Check for a minecraft server and download it if necessary
|
||||
minecraft() {
|
||||
echo ""
|
||||
if [[ "${MODLOADER}" == "Fabric" && "$IMPROVED_FABRIC_LAUNCHER_AVAILABLE" == "200" ]]; then
|
||||
echo "Skipping Minecraft Server JAR checks because we are using the improved Fabric Server Launcher."
|
||||
else
|
||||
downloadIfNotExist "${MINECRAFT_SERVER_JAR_LOCATION}" "${MINECRAFT_SERVER_JAR_LOCATION}" "${MINECRAFT_SERVER_URL}" >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Check for eula.txt and generate if necessary
|
||||
eula() {
|
||||
echo ""
|
||||
if [[ ! -s "eula.txt" ]]; then
|
||||
|
||||
echo "Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA."
|
||||
echo "Mojang's EULA is available to read at https://aka.ms/MinecraftEULA"
|
||||
echo "If you agree to Mojang's EULA then type 'I agree'"
|
||||
echo -n "Response: "
|
||||
read -r ANSWER
|
||||
|
||||
if [[ "${ANSWER}" == "I agree" ]]; then
|
||||
echo "User agreed to Mojang's EULA."
|
||||
echo "#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA)." >eula.txt
|
||||
echo "eula=true" >>eula.txt
|
||||
else
|
||||
echo "User did not agree to Mojang's EULA."
|
||||
echo "Entered: ${ANSWER}"
|
||||
crash
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
# Main
|
||||
case ${MODLOADER} in
|
||||
|
||||
"Forge")
|
||||
setup_forge
|
||||
;;
|
||||
|
||||
"NeoForge")
|
||||
setup_neoforge
|
||||
;;
|
||||
|
||||
"Fabric")
|
||||
setup_fabric
|
||||
;;
|
||||
|
||||
"Quilt")
|
||||
setup_quilt
|
||||
;;
|
||||
|
||||
"LegacyFabric")
|
||||
setup_legacyfabric
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Incorrect modloader specified: ${MODLOADER}"
|
||||
crash
|
||||
esac
|
||||
|
||||
if [[ "${PWD}" == *" "* ]]; then
|
||||
|
||||
echo "WARNING! The current location of this script contains spaces. This may cause this server to crash!"
|
||||
echo "It is strongly recommended to move this server pack to a location whose path does NOT contain SPACES!"
|
||||
echo ""
|
||||
echo "Current path:"
|
||||
echo "${PWD}"
|
||||
echo ""
|
||||
echo -n "Are you sure you want to continue? (Yes/No): "
|
||||
read -r WHY
|
||||
|
||||
if [[ "${WHY}" == "Yes" ]]; then
|
||||
echo "Alrighty. Prepare for unforseen consequences, Mr. Freeman..."
|
||||
else
|
||||
crash
|
||||
fi
|
||||
fi
|
||||
|
||||
checkJavaBitness
|
||||
minecraft
|
||||
eula
|
||||
|
||||
echo ""
|
||||
echo "Starting server..."
|
||||
echo "Minecraft version: ${MINECRAFT_VERSION}"
|
||||
echo "Modloader: ${MODLOADER}"
|
||||
echo "Modloader version: ${MODLOADER_VERSION}"
|
||||
if [[ ${LAUNCHER_JAR_LOCATION} != "do_not_manually_edit" ]]; then
|
||||
echo "Launcher JAR: ${LAUNCHER_JAR_LOCATION}"
|
||||
fi
|
||||
echo ""
|
||||
echo "Java args: ${JAVA_ARGS}"
|
||||
echo "Java path: ${JAVA}"
|
||||
echo "Run Command: ${JAVA} ${SERVER_RUN_COMMAND}"
|
||||
echo "Java version:"
|
||||
"${JAVA}" -version
|
||||
echo ""
|
||||
|
||||
runJavaCommand "${SERVER_RUN_COMMAND}"
|
||||
|
||||
echo ""
|
||||
echo "Exiting..."
|
||||
read -n 1 -s -r -p "Press any key to continue"
|
||||
exit 0
|
3
minecraft/stop.sh
Executable file
3
minecraft/stop.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
/opt/mcrcon/mcrcon -p jEPqvH2oWs5v stop
|
14
mkvedit.sh
Executable file
14
mkvedit.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
disable_track=2
|
||||
enable_track=1
|
||||
enable_sub_track=4
|
||||
disable_sub_track=5
|
||||
|
||||
|
||||
for f in ./*.mkv; do
|
||||
mkvpropedit "$f" --edit track:a$disable_track --set flag-default=0;
|
||||
mkvpropedit "$f" --edit track:a$enable_track --set flag-default=1;
|
||||
mkvpropedit "$f" --edit track:s$disable_sub_track --set flag-default=0;
|
||||
mkvpropedit "$f" --edit track:s$enable_sub_track --set flag-default=1;
|
||||
done
|
||||
|
174
open_with_linux.py
Executable file
174
open_with_linux.py
Executable file
@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import struct
|
||||
import subprocess
|
||||
|
||||
VERSION = '7.2.6'
|
||||
|
||||
try:
|
||||
sys.stdin.buffer
|
||||
|
||||
# Python 3.x version
|
||||
# Read a message from stdin and decode it.
|
||||
def getMessage():
|
||||
rawLength = sys.stdin.buffer.read(4)
|
||||
if len(rawLength) == 0:
|
||||
sys.exit(0)
|
||||
messageLength = struct.unpack('@I', rawLength)[0]
|
||||
message = sys.stdin.buffer.read(messageLength).decode('utf-8')
|
||||
return json.loads(message)
|
||||
|
||||
# Send an encoded message to stdout
|
||||
def sendMessage(messageContent):
|
||||
encodedContent = json.dumps(messageContent).encode('utf-8')
|
||||
encodedLength = struct.pack('@I', len(encodedContent))
|
||||
|
||||
sys.stdout.buffer.write(encodedLength)
|
||||
sys.stdout.buffer.write(encodedContent)
|
||||
sys.stdout.buffer.flush()
|
||||
|
||||
except AttributeError:
|
||||
# Python 2.x version (if sys.stdin.buffer is not defined)
|
||||
print('Python 3.2 or newer is required.')
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
def install():
|
||||
home_path = os.getenv('HOME')
|
||||
|
||||
manifest = {
|
||||
'name': 'open_with',
|
||||
'description': 'Open With native host',
|
||||
'path': os.path.realpath(__file__),
|
||||
'type': 'stdio',
|
||||
}
|
||||
locations = {
|
||||
'chrome': os.path.join(home_path, '.config', 'google-chrome', 'NativeMessagingHosts'),
|
||||
'chrome-beta': os.path.join(home_path, '.config', 'google-chrome-beta', 'NativeMessagingHosts'),
|
||||
'chrome-unstable': os.path.join(home_path, '.config', 'google-chrome-unstable', 'NativeMessagingHosts'),
|
||||
'chromium': os.path.join(home_path, '.config', 'chromium', 'NativeMessagingHosts'),
|
||||
'firefox': os.path.join(home_path, '.mozilla', 'native-messaging-hosts'),
|
||||
'thunderbird': os.path.join(home_path, '.thunderbird', 'native-messaging-hosts'),
|
||||
}
|
||||
filename = 'open_with.json'
|
||||
|
||||
for browser, location in locations.items():
|
||||
if os.path.exists(os.path.dirname(location)):
|
||||
if not os.path.exists(location):
|
||||
os.mkdir(location)
|
||||
|
||||
browser_manifest = manifest.copy()
|
||||
if browser in ['firefox', 'thunderbird']:
|
||||
browser_manifest['allowed_extensions'] = ['openwith@darktrojan.net']
|
||||
else:
|
||||
browser_manifest['allowed_origins'] = [
|
||||
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/', # Chrome
|
||||
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/', # Opera
|
||||
]
|
||||
|
||||
with open(os.path.join(location, filename), 'w') as file:
|
||||
file.write(
|
||||
json.dumps(browser_manifest, indent=2, separators=(',', ': '), sort_keys=True).replace(' ', '\t') + '\n'
|
||||
)
|
||||
|
||||
|
||||
def _read_desktop_file(path):
|
||||
with open(path, 'r') as desktop_file:
|
||||
current_section = None
|
||||
name = None
|
||||
command = None
|
||||
for line in desktop_file:
|
||||
if line[0] == '[':
|
||||
current_section = line[1:-2]
|
||||
if current_section != 'Desktop Entry':
|
||||
continue
|
||||
|
||||
if line.startswith('Name='):
|
||||
name = line[5:].strip()
|
||||
elif line.startswith('Exec='):
|
||||
command = line[5:].strip()
|
||||
|
||||
return {
|
||||
'name': name,
|
||||
'command': command
|
||||
}
|
||||
|
||||
|
||||
def find_browsers():
|
||||
apps = [
|
||||
'Chrome',
|
||||
'Chromium',
|
||||
'chromium',
|
||||
'chromium-browser',
|
||||
'firefox',
|
||||
'Firefox',
|
||||
'Google Chrome',
|
||||
'google-chrome',
|
||||
'opera',
|
||||
'Opera',
|
||||
'SeaMonkey',
|
||||
'seamonkey',
|
||||
]
|
||||
paths = [
|
||||
os.path.join(os.getenv('HOME'), '.local/share/applications'),
|
||||
'/usr/local/share/applications',
|
||||
'/usr/share/applications'
|
||||
]
|
||||
suffix = '.desktop'
|
||||
|
||||
results = []
|
||||
for p in paths:
|
||||
for a in apps:
|
||||
fp = os.path.join(p, a) + suffix
|
||||
if os.path.exists(fp):
|
||||
results.append(_read_desktop_file(fp))
|
||||
return results
|
||||
|
||||
|
||||
def listen():
|
||||
receivedMessage = getMessage()
|
||||
if receivedMessage == 'ping':
|
||||
sendMessage({
|
||||
'version': VERSION,
|
||||
'file': os.path.realpath(__file__)
|
||||
})
|
||||
elif receivedMessage == 'find':
|
||||
sendMessage(find_browsers())
|
||||
else:
|
||||
for k, v in os.environ.items():
|
||||
if k.startswith('MOZ_'):
|
||||
try:
|
||||
os.unsetenv(k)
|
||||
except:
|
||||
os.environ[k] = ''
|
||||
|
||||
devnull = open(os.devnull, 'w')
|
||||
subprocess.Popen(receivedMessage, stdout=devnull, stderr=devnull)
|
||||
sendMessage(None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 2:
|
||||
if sys.argv[1] == 'install':
|
||||
install()
|
||||
sys.exit(0)
|
||||
elif sys.argv[1] == 'find_browsers':
|
||||
print(find_browsers())
|
||||
sys.exit(0)
|
||||
|
||||
allowed_extensions = [
|
||||
'openwith@darktrojan.net',
|
||||
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/',
|
||||
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/',
|
||||
]
|
||||
for ae in allowed_extensions:
|
||||
if ae in sys.argv:
|
||||
listen()
|
||||
sys.exit(0)
|
||||
|
||||
print('This is the Open With native helper, version %s.' % VERSION)
|
||||
print('Run this script again with the word "install" after the file name to install.')
|
17
playbooks/config-backup.yml
Normal file
17
playbooks/config-backup.yml
Normal file
@ -0,0 +1,17 @@
|
||||
- name: Backup config to git repo@nas
|
||||
hosts: localhost
|
||||
|
||||
vars:
|
||||
src_dirs:
|
||||
- "/home/belar/.config/"
|
||||
- "/etc"
|
||||
dst_dir: "/home/belar/nas_belar/backup/hotaru/"
|
||||
commit_msg: "Config backup {{ ansible_date_time.iso8601 }}"
|
||||
|
||||
tasks:
|
||||
- name: Copy files to destination
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ dst_dir }}/{{ item | basename }}"
|
||||
with_items:
|
||||
- "{{ src_dirs }}"
|
103
playbooks/ios_cfgback.yml
Normal file
103
playbooks/ios_cfgback.yml
Normal file
@ -0,0 +1,103 @@
|
||||
# Playbook to backup running configs from (Cisco IOS) network devices to Git
|
||||
#
|
||||
# Gather the config via ios_facts, store it in the local directory {{ config_path }}
|
||||
# Sanitize config files / remove lines with timestamps like {{ timestamp_line_identifier }}
|
||||
# Commit to git, only if neccessary
|
||||
# Report all steps to {{ syslog_host }}
|
||||
#
|
||||
# You might want to change the vars config_path, syslog_host and timestamp_line_identifier
|
||||
# Uncomment the line 'git push -f origin master' if you want to push to a central repo like GitHub/Lab
|
||||
|
||||
|
||||
---
|
||||
- name: CONFIG BACKUP TO LOCAL DIRECTORY
|
||||
hosts: all
|
||||
connection: network_cli
|
||||
ignore_errors: yes
|
||||
gather_facts: no
|
||||
|
||||
vars:
|
||||
config_path: /home/nwmichl/configs
|
||||
syslog_host: 192.168.1.12
|
||||
timestamp_line_identifier: "! Last configuration"
|
||||
|
||||
tasks:
|
||||
|
||||
- name: GATHER FACTS VIA SSH
|
||||
ios_facts:
|
||||
gather_subset:
|
||||
- config
|
||||
register: ios_facts_result
|
||||
when: ansible_network_os == 'ios'
|
||||
|
||||
- name: SYSLOG MESSAGE - GATHER FACTS ERROR
|
||||
shell: |
|
||||
logger -n {{ syslog_host }} -p local0.error --udp Config Backup of "{{ inventory_hostname }}" GATHER FACTS FAILED because "{{ ios_facts_result.msg }}"
|
||||
when: "ansible_network_os == 'ios' and ios_facts_result.failed"
|
||||
|
||||
- name: SAVE CONFIG TO FILE
|
||||
local_action: copy content={{ ansible_net_config }} dest={{ config_path }}/{{ inventory_hostname }}.txt
|
||||
register: save_result
|
||||
when: "ansible_network_os == 'ios' and not ios_facts_result.failed"
|
||||
|
||||
- name: SYSLOG MESSAGE - SAVE CONFIG ERROR
|
||||
shell: |
|
||||
logger -n {{ syslog_host }} -p local0.error --udp Config Backup of "{{ inventory_hostname }}" SAVE FAILED because "{{ save_result.msg }}"
|
||||
when: "ansible_network_os == 'ios' and save_result.failed"
|
||||
|
||||
- name: SYSLOG MESSAGE - SUCCESSFUL
|
||||
shell: |
|
||||
logger -n {{ syslog_host }} -p local0.notice --udp Config Backup of "{{ inventory_hostname }}" successful
|
||||
when: "ansible_network_os == 'ios' and not ios_facts_result.failed and not save_result.failed"
|
||||
|
||||
- name: REMOVE CONFIG LINES WITH TIMESTAMPS
|
||||
lineinfile:
|
||||
path: "{{ config_path }}/{{ inventory_hostname }}.txt"
|
||||
state: absent
|
||||
regexp: '^{{ timestamp_line_identifier }}'
|
||||
delegate_to: localhost
|
||||
|
||||
#
|
||||
# The following tasks will only be executed once
|
||||
#
|
||||
|
||||
- name: GIT - ADD ALL (NEW) FILES AND CHECK IF WORKING DIRECTORY IS DIRTY => FAILED
|
||||
shell: |
|
||||
cd {{ config_path }}/
|
||||
git add --all .
|
||||
git diff-index --quiet HEAD #Return code = 0 if working directory is clean and 1 if dirty
|
||||
delegate_to: localhost
|
||||
register: git_result
|
||||
run_once: true
|
||||
|
||||
- name: SYSLOG MESSAGE - Git Dir clean - Nothing to commit
|
||||
shell: |
|
||||
logger -n {{ syslog_host }} -p local0.notice --udp Config Backup - GIT Working Directory {{ config_path }} is clean - Nothing to commit
|
||||
when: not git_result.failed
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
- name: GIT - COMMIT/PUSH ONLY IF WORKING DIRECTORY IS DIRTY
|
||||
shell: |
|
||||
cd {{ config_path }}/
|
||||
git commit -m "Config backup taken $(date +"%Y-%m-%d %H:%M:%S")"
|
||||
# git push -f origin master
|
||||
delegate_to: localhost
|
||||
register: gitcommit_result
|
||||
run_once: true
|
||||
when: git_result.failed
|
||||
|
||||
- name: SYSLOG MESSAGE - GIT COMMIT/PUSH SUCCESSFUL
|
||||
shell: |
|
||||
logger -n {{ syslog_host }} -p local0.notice --udp Config Backup - GIT Commit / Push successful
|
||||
when: gitcommit_result.failed is defined and not gitcommit_result.failed
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
||||
- name: SYSLOG MESSAGE - GIT COMMIT/PUSH ERROR
|
||||
shell: |
|
||||
logger -n {{ syslog_host }} -p local0.error --udp Config Backup - GIT Commit / Push FAILED !
|
||||
when: gitcommit_result.failed is defined and gitcommit_result.failed
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
15
random_name.sh
Normal file
15
random_name.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Directory containing the MP4 files
|
||||
directory="/mnt/red/porn/HydraFXX/uniform"
|
||||
|
||||
# Find all MP4 files and rename them with random names
|
||||
find "$directory" -type f -name "*.mp4" | while read -r file; do
|
||||
# Generate a random name
|
||||
random_name=$(uuidgen)
|
||||
# Get the directory of the file
|
||||
dir=$(dirname "$file")
|
||||
# Rename the file
|
||||
mv "$file" "$dir/$random_name.mp4"
|
||||
done
|
||||
|
143
shell-mommy.sh
Normal file
143
shell-mommy.sh
Normal file
@ -0,0 +1,143 @@
|
||||
# sudofox/shell-mommy.sh
|
||||
|
||||
mommy() (
|
||||
|
||||
# SHELL_MOMMYS_LITTLE - what to call you~ (default: "girl")
|
||||
# SHELL_MOMMYS_PRONOUNS - what pronouns mommy will use for themself~ (default: "her")
|
||||
# SHELL_MOMMYS_ROLES - what role mommy will have~ (default "mommy")
|
||||
|
||||
COLORS_LIGHT_PINK='\e[38;5;217m'
|
||||
COLORS_LIGHT_BLUE='\e[38;5;117m'
|
||||
COLORS_FAINT='\e[2m'
|
||||
COLORS_RESET='\e[0m'
|
||||
|
||||
DEF_WORDS_LITTLE="girl"
|
||||
DEF_WORDS_PRONOUNS="her"
|
||||
DEF_WORDS_ROLES="mommy"
|
||||
DEF_MOMMY_COLOR="${COLORS_LIGHT_PINK}"
|
||||
DEF_ONLY_NEGATIVE="false"
|
||||
|
||||
NEGATIVE_RESPONSES="do you need MOMMYS_ROLE's help~? ❤️
|
||||
Don't give up, my love~ ❤️
|
||||
Don't worry, MOMMYS_ROLE is here to help you~ ❤️
|
||||
I believe in you, my sweet AFFECTIONATE_TERM~ ❤️
|
||||
It's okay to make mistakes, my dear~ ❤️
|
||||
just a little further, sweetie~ ❤️
|
||||
Let's try again together, okay~? ❤️
|
||||
MOMMYS_ROLE believes in you, and knows you can overcome this~ ❤️
|
||||
MOMMYS_ROLE believes in you~ ❤️
|
||||
MOMMYS_ROLE is always here for you, no matter what~ ❤️
|
||||
MOMMYS_ROLE is here to help you through it~ ❤️
|
||||
MOMMYS_ROLE is proud of you for trying, no matter what the outcome~ ❤️
|
||||
MOMMYS_ROLE knows it's tough, but you can do it~ ❤️
|
||||
MOMMYS_ROLE knows MOMMYS_PRONOUN little AFFECTIONATE_TERM can do better~ ❤️
|
||||
MOMMYS_ROLE knows you can do it, even if it's tough~ ❤️
|
||||
MOMMYS_ROLE knows you're feeling down, but you'll get through it~ ❤️
|
||||
MOMMYS_ROLE knows you're trying your best~ ❤️
|
||||
MOMMYS_ROLE loves you, and is here to support you~ ❤️
|
||||
MOMMYS_ROLE still loves you no matter what~ ❤️
|
||||
You're doing your best, and that's all that matters to MOMMYS_ROLE~ ❤️
|
||||
MOMMYS_ROLE is always here to encourage you~ ❤️"
|
||||
|
||||
POSITIVE_RESPONSES="*pets your head*
|
||||
awe, what a good AFFECTIONATE_TERM~\nMOMMYS_ROLE knew you could do it~ ❤️
|
||||
good AFFECTIONATE_TERM~\nMOMMYS_ROLE's so proud of you~ ❤️
|
||||
Keep up the good work, my love~ ❤️
|
||||
MOMMYS_ROLE is proud of the progress you've made~ ❤️
|
||||
MOMMYS_ROLE is so grateful to have you as MOMMYS_PRONOUN little AFFECTIONATE_TERM~ ❤️
|
||||
I'm so proud of you, my love~ ❤️
|
||||
MOMMYS_ROLE is so proud of you~ ❤️
|
||||
MOMMYS_ROLE loves seeing MOMMYS_PRONOUN little AFFECTIONATE_TERM succeed~ ❤️
|
||||
MOMMYS_ROLE thinks MOMMYS_PRONOUN little AFFECTIONATE_TERM earned a big hug~ ❤️
|
||||
that's a good AFFECTIONATE_TERM~ ❤️
|
||||
you did an amazing job, my dear~ ❤️
|
||||
you're such a smart cookie~ ❤️"
|
||||
|
||||
# allow for overriding of default words (IF ANY SET)
|
||||
|
||||
if [ -n "$SHELL_MOMMYS_LITTLE" ]; then
|
||||
DEF_WORDS_LITTLE="${SHELL_MOMMYS_LITTLE}"
|
||||
fi
|
||||
if [ -n "$SHELL_MOMMYS_PRONOUNS" ]; then
|
||||
DEF_WORDS_PRONOUNS="${SHELL_MOMMYS_PRONOUNS}"
|
||||
fi
|
||||
if [ -n "$SHELL_MOMMYS_ROLES" ]; then
|
||||
DEF_WORDS_ROLES="${SHELL_MOMMYS_ROLES}"
|
||||
fi
|
||||
if [ -n "$SHELL_MOMMYS_COLOR" ]; then
|
||||
DEF_MOMMY_COLOR="${SHELL_MOMMYS_COLOR}"
|
||||
fi
|
||||
# allow overriding to true
|
||||
if [ "$SHELL_MOMMYS_ONLY_NEGATIVE" = "true" ]; then
|
||||
DEF_ONLY_NEGATIVE="true"
|
||||
fi
|
||||
# if the variable is set for positive/negative responses, overwrite it
|
||||
if [ -n "$SHELL_MOMMYS_POSITIVE_RESPONSES" ]; then
|
||||
POSITIVE_RESPONSES="$SHELL_MOMMYS_POSITIVE_RESPONSES"
|
||||
fi
|
||||
if [ -n "$SHELL_MOMMYS_NEGATIVE_RESPONSES" ]; then
|
||||
NEGATIVE_RESPONSES="$SHELL_MOMMYS_NEGATIVE_RESPONSES"
|
||||
fi
|
||||
|
||||
# split a string on forward slashes and return a random element
|
||||
pick_word() {
|
||||
echo "$1" | tr '/' '\n' | shuf | sed 1q
|
||||
}
|
||||
|
||||
pick_response() { # given a response type, pick an entry from the list
|
||||
|
||||
if [ "$1" = "positive" ]; then
|
||||
element=$(echo "$POSITIVE_RESPONSES" | shuf | sed 1q)
|
||||
elif [ "$1" = "negative" ]; then
|
||||
element=$(echo "$NEGATIVE_RESPONSES" | shuf | sed 1q)
|
||||
else
|
||||
echo "Invalid response type: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Return the selected response
|
||||
echo "$element"
|
||||
|
||||
}
|
||||
|
||||
sub_terms() { # given a response, sub in the appropriate terms
|
||||
response="$1"
|
||||
# pick_word for each term
|
||||
affectionate_term="$(pick_word "${DEF_WORDS_LITTLE}")"
|
||||
pronoun="$(pick_word "${DEF_WORDS_PRONOUNS}")"
|
||||
role="$(pick_word "${DEF_WORDS_ROLES}")"
|
||||
# sub in the terms, store in variable
|
||||
response="$(echo "$response" | sed "s/AFFECTIONATE_TERM/$affectionate_term/g")"
|
||||
response="$(echo "$response" | sed "s/MOMMYS_PRONOUN/$pronoun/g")"
|
||||
response="$(echo "$response" | sed "s/MOMMYS_ROLE/$role/g")"
|
||||
# we have string literal newlines in the response, so we need to printf it out
|
||||
# print faint and colorcode
|
||||
printf "${DEF_MOMMY_COLOR}$response${COLORS_RESET}\n"
|
||||
}
|
||||
|
||||
success() {
|
||||
(
|
||||
# if we're only supposed to show negative responses, return
|
||||
if [ "$DEF_ONLY_NEGATIVE" = "true" ]; then
|
||||
return 0
|
||||
fi
|
||||
# pick_response for the response type
|
||||
response="$(pick_response "positive")"
|
||||
sub_terms "$response" >&2
|
||||
)
|
||||
return 0
|
||||
}
|
||||
failure() {
|
||||
rc=$?
|
||||
(
|
||||
response="$(pick_response "negative")"
|
||||
sub_terms "$response" >&2
|
||||
)
|
||||
return $rc
|
||||
}
|
||||
# eval is used here to allow for alias resolution
|
||||
|
||||
# TODO: add a way to check if we're running from PROMPT_COMMAND to use the previous exit code instead of doing things this way
|
||||
eval "$@" && success || failure
|
||||
return $?
|
||||
)
|
283
sixcat
Executable file
283
sixcat
Executable file
@ -0,0 +1,283 @@
|
||||
#!/bin/bash
|
||||
|
||||
# sixcat: Use sixel graphics to show an image inside a terminal.
|
||||
# sixgif: Use sixel graphics to play an animation inside a terminal.
|
||||
|
||||
# Version 1.0
|
||||
# hackerb9, June 2017
|
||||
|
||||
# Sixel graphics are supported by terminals such as the DEC VT340 and
|
||||
# emulators, such as 'xterm -ti vt340'.
|
||||
|
||||
# ImageMagick is required. (apt-get install imagemagick)
|
||||
|
||||
# The heart of this program is really just one line:
|
||||
#
|
||||
# convert foo.jpg sixel:-
|
||||
#
|
||||
# All the other lines are bells and whistles, mostly to make the image
|
||||
# look better by increasing the number of colors available.
|
||||
|
||||
|
||||
######################################################################
|
||||
# Configuration
|
||||
######################################################################
|
||||
|
||||
# Number of colors in the terminal's sixel palette.
|
||||
# (But also see the -x and -n options).
|
||||
default_numcolors=16 # Genuine vt340's had a 16-color palette.
|
||||
|
||||
# Maximum image size is terminal dependent, so we have to guess.
|
||||
geometry="-geometry 800x480>" # this was the actual vt340 resolution
|
||||
#geometry="-geometry 800x800>" # allows for portrait orientation
|
||||
#geometry="-geometry 1000x1000>" # maximum allowed in xterm322
|
||||
|
||||
# Should ImageMagick dither the image to make it look better?
|
||||
# (Use dither="" to disable.)
|
||||
dither="-dither floyd-steinberg"
|
||||
|
||||
# Maximum number of seconds to wait for a response from the terminal
|
||||
# after a color escape sequence request. Usually, terminals respond
|
||||
# much faster than 0.1 seconds, but I could imagine it needing to be
|
||||
# increased for slow links (e.g., RS232C).
|
||||
timeout=0.1
|
||||
|
||||
|
||||
######################################################################
|
||||
# Helper functions
|
||||
######################################################################
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename $0) [-x|-X|-n INTEGER] <imagefiles...>
|
||||
|
||||
-x: Force the use of xterm escape sequences to detect and
|
||||
change the palette size instead of defaulting to $default_numcolors.
|
||||
If the palette is smaller than 1024, it is set to 1024.
|
||||
|
||||
Note that -x is the default if \$TERM is "xterm".
|
||||
|
||||
-X: Just assume palette size is $default_numcolors.
|
||||
Does not use xterm escape sequences regardless of \$TERM.
|
||||
|
||||
-n INTEGER:
|
||||
Assume pallete size is INTEGER.
|
||||
Does not use xterm escape sequences regardless of \$TERM.
|
||||
|
||||
Note: if this program is called sixgif, it will play GIF animations
|
||||
in the top left instead of scrolling all the frames as multiple images.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
# Some functions to deal with checking and changing the number of
|
||||
# colors the terminal can show. Likely xterm specific, but YMMV.
|
||||
|
||||
getnumcolors() {
|
||||
# Query xterm for the palette size and print it.
|
||||
# (Negative numbers indicate errors.)
|
||||
colors 1 0
|
||||
}
|
||||
|
||||
resetnumcolors() {
|
||||
# Reset xterm back to its default number of colors.
|
||||
# Print the new number of colors (negative if an error occurred.)
|
||||
colors 2 0
|
||||
}
|
||||
|
||||
setnumcolors() {
|
||||
# Request xterm to change the number of colors in its palette.
|
||||
# Print the new number of colors (negative if an error occurred.)
|
||||
colors 3 $1
|
||||
}
|
||||
|
||||
colors() {
|
||||
# Send an xterm escape code request in the form: ^[[?1;3;1024S
|
||||
# Print the response value (or a negative number if an error occurs)
|
||||
csi=$'\e['
|
||||
action=$1 # Action. 1 to get, 2 to reset, 3 to set
|
||||
value=$2 # Number of colors to set
|
||||
returnvalue=-1
|
||||
|
||||
# Raw response is in the same form as request: ^[[?1;0;1024S
|
||||
# Let's parse it to be more manageable.
|
||||
IFS=";" \
|
||||
read -a REPLY -s -t $timeout -d "S" \
|
||||
-p "${csi}?1;${action};${value}S"
|
||||
|
||||
if [[ $? != 0 || ${#REPLY} == 0 ]]; then
|
||||
# No response to VT escape sequence. Maybe you are not an xterm?
|
||||
# Or, perhaps timeout is too short?
|
||||
returnvalue=-2
|
||||
elif [[ "${REPLY[1]}" == "3" ]]; then
|
||||
# Response code 3 means error. Likely too many colors requested.
|
||||
returnvalue=-3
|
||||
elif [[ "${REPLY[1]}" == "0" ]] ; then
|
||||
# 0 means okay. Yay!
|
||||
returnvalue=${REPLY[2]}
|
||||
else
|
||||
# If we get here, response was not in the format we expected.
|
||||
# Perhaps user typed during xterm response? Or cosmic rays?
|
||||
returnvalue=-4
|
||||
fi
|
||||
|
||||
echo $returnvalue
|
||||
}
|
||||
|
||||
waitforterminal() {
|
||||
# Send an escape sequence and wait for a response from the terminal.
|
||||
# This routine will let us know when an image transfer has finished
|
||||
# and it's okay to send escape sequences that request results.
|
||||
# (E.g., if we want to run resetnumcolors at the end of the program.)
|
||||
# WARNING. While this should work with any terminal, if it fails,
|
||||
# it'll end up waiting for approximately *forever* (i.e., 60 seconds).
|
||||
read -s -t 60 -d "c" -p $'\e[c'
|
||||
}
|
||||
|
||||
|
||||
debugeta() {
|
||||
# Given a number of bytes, estimate the amount of time its going
|
||||
# to take to send at the current TTY baud rate.
|
||||
# Mostly for larks as this will be completely bogus on terminal emulators.
|
||||
|
||||
len=$1
|
||||
|
||||
# Static variables to store TTY type and STTY speed.
|
||||
[[ "$TTY" ]] || TTY=$(tty)
|
||||
[[ "$SPEED" ]] || SPEED=$(stty speed) || SPEED=0
|
||||
|
||||
echo "sixel command length is $len bytes"
|
||||
|
||||
if [[ "$SPEED" -gt 0 ]]; then
|
||||
if [[ "$TTY" =~ /pt || "$TTY" =~ ttyp ]]; then
|
||||
echo "pseudoterminal detected (speed estimates only valid for real hardware)"
|
||||
fi
|
||||
echo "terminal speed is $SPEED bps"
|
||||
echo "estimated time to send: $((len*8/SPEED)) seconds"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# If the user hits ^C, we don't want them stuck in SIXEL mode
|
||||
cleanup() {
|
||||
echo -n $'\e[?80h' # Reenable sixel scrolling
|
||||
echo -n $'\e\\' # Escape sequence to stop SIXEL
|
||||
exit 0
|
||||
}
|
||||
trap cleanup SIGINT SIGHUP SIGABRT
|
||||
|
||||
|
||||
######################################################################
|
||||
# MAIN BEGINS HERE
|
||||
######################################################################
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
usage
|
||||
exit 1
|
||||
else
|
||||
case "$1" in
|
||||
-n|--num-colors) shift
|
||||
nflag="$1"
|
||||
shift
|
||||
# Just assume the palette is n colors. Do not bother checking or changing.
|
||||
# (Might be needed for some terminal emulators. I do not know.)
|
||||
if [[ "$nflag" -gt 0 ]]; then
|
||||
default_numcolors=$nflag
|
||||
else
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-x|--force-xterm-colors) shift
|
||||
# Force xterm palette manipulation, regardless of $TERM
|
||||
# (Might be needed for some terminal emulators. I do not know.)
|
||||
xflag=yup
|
||||
;;
|
||||
-X|--disable-xterm-colors) shift
|
||||
# Disable xterm palette manipulation, regardless of $TERM
|
||||
# (Might be needed for some terminal emulators. I do not know.)
|
||||
Xflag=yup
|
||||
;;
|
||||
-*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
|
||||
numcolors=$default_numcolors
|
||||
|
||||
# Optionally detect and set the number of palette colors
|
||||
if [[ "$xflag" || -z "$Xflag" && -z "$nflag" && "$TERM" =~ ^xterm ]]; then
|
||||
# Since the VT340 only had a palette of 16 colors, we can vastly
|
||||
# improve the image if we tell xterm to increase it to 1024.
|
||||
# This would fail on a real VT340.
|
||||
palettechanged=yup
|
||||
oldnumcolors=$(getnumcolors)
|
||||
if [[ $oldnumcolors -lt 1024 ]]; then
|
||||
numcolors=$(setnumcolors 1024)
|
||||
if [[ $numcolors -le 0 ]]; then
|
||||
echo -e "\rTerminal did not accept escape sequence to increase color palette. Are you really an xterm?" >&2
|
||||
numcolors=$default_numcolors
|
||||
fi
|
||||
else
|
||||
# At least 1024 colors, so do not change anything
|
||||
numcolors=$oldnumcolors
|
||||
palettechanged=
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Small optimization (saves half a second)
|
||||
if [[ $numcolors == 1024 ]]; then
|
||||
# Imagemagick already defaults to 1024 colors for sixel
|
||||
colors=""
|
||||
else
|
||||
colors="-colors $numcolors"
|
||||
fi
|
||||
|
||||
|
||||
# Print image filename after showing it? Yes, if multiple files.
|
||||
if [[ $# -gt 1 ]]; then
|
||||
showname=yup
|
||||
else
|
||||
showname=""
|
||||
fi
|
||||
|
||||
|
||||
# PAST IS PROLOGUE... NOW TO THE MEAT.
|
||||
for f; do
|
||||
x=$(convert "$f" $geometry $colors sixel:- 2>/dev/null)
|
||||
[[ ${#x} != 0 ]] || continue # The sixel command length better be >0
|
||||
|
||||
: debugeta ${#x}
|
||||
|
||||
case $0 in
|
||||
*sixgif)
|
||||
# If this program is named "sixgif" play files as animations,
|
||||
# instead of displaying each frame and scrolling down.
|
||||
echo -n $'\e[?80l' # Disable sixel scrolling
|
||||
for t in {1..3}; do
|
||||
echo -n "$x" # sixgif plays repeatedly
|
||||
done
|
||||
echo -n $'\e[?80h' # Reenable sixel scrolling
|
||||
;;
|
||||
|
||||
*)
|
||||
echo -n "$x" # sixcat just shows once
|
||||
[[ "$showname" ]] && echo "$f"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# TIDY UP
|
||||
waitforterminal
|
||||
if [[ "$palettechanged" ]]; then
|
||||
# Reset color palette
|
||||
numcolors=$(resetnumcolors)
|
||||
: echo Number of colors reset to $numcolors >&2
|
||||
fi
|
4
startup_gns3.sh
Normal file
4
startup_gns3.sh
Normal file
@ -0,0 +1,4 @@
|
||||
sudo systemctl start docker
|
||||
sudo systemctl start virtqemud
|
||||
sudo systemctl start libvirtd
|
||||
sudo systemctl start gns3-server@belar
|
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
STATE=$(mozillavpn status | grep "VPN state" | awk '{print $3}')
|
||||
|
||||
|
||||
if [ "$STATE" == "off" ]; then
|
||||
mozillavpn activate
|
||||
notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Activated"
|
||||
fi
|
||||
|
||||
if [ "$STATE" == "on" ]; then
|
||||
mozillavpn deactivate
|
||||
notify-send -i /usr/share/icons/hicolor/32x32/apps/mozillavpn.png "Mozilla VPN" "VPN Deactivated"
|
||||
fi
|
22
toggle-tailscale-exit-node.sh
Normal file
22
toggle-tailscale-exit-node.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
EXIT_NODE=tailscale-jumphost
|
||||
STATE=$(tailscale status | grep "$EXIT_NODE" | awk -F ';' '{print $2}' | tr -d ' ')
|
||||
|
||||
if [ "$STATE" == "offersexitnode" ]; then
|
||||
sudo tailscale set --exit-node=tailscale-jumphost.tailf6c9a.ts.net.
|
||||
if ping -c 192.168.0.1 > /dev/null 2>&1; then
|
||||
notify-send -i ${HOME}/.scripts/icons/tailscale.png "Tailscale Exit Node" "Tunnel Activated: $EXIT_NODE"
|
||||
else
|
||||
notify-send --urgency=critical -i ${HOME}/.scripts/icons/tailscale.png "Tailscale Exit Node" "Error"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$STATE" == "exitnode" ]; then
|
||||
sudo tailscale set --exit-node=
|
||||
if ping -c 1 1.1.1.1 > /dev/null 2>&1; then
|
||||
notify-send -i ${HOME}/.scripts/icons/tailscale.png "Tailscale Exit Node" "Tunnel Deactivated"
|
||||
else
|
||||
notify-send --urgency=critical -i ${HOME}/.scripts/icons/tailscale.png "Tailscale Exit Node" "Error"
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user