Merge branch 'main' of github.com:nidionis/svr
This commit is contained in:
@@ -39,16 +39,20 @@ echo "iso = $ISO"
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-m $RAM \
|
||||
-nic user \
|
||||
-boot once=d \
|
||||
-cdrom $ISO \
|
||||
-drive file=$IMG \
|
||||
-display none \
|
||||
-device virtio-vga \
|
||||
-enable-kvm \
|
||||
-display default,show-cursor=on \
|
||||
-net user,hostfwd=tcp::7777-:22
|
||||
-net nic
|
||||
#-virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare
|
||||
|
||||
-device virtio-vga \
|
||||
-enable-kvm \
|
||||
-display default,show-cursor=on \
|
||||
-display none \
|
||||
-virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare
|
||||
|
||||
## --- Run QEMU with graphics + shared folder ---
|
||||
#qemu-system-x86_64 \
|
||||
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SDX="${1:-sdb}"
|
||||
|
||||
BOOT="${SDX}1"
|
||||
ROOT="${SDX}2"
|
||||
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
echo "Run as root."
|
||||
echo "sdx as parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Target: /dev/${SDX}"
|
||||
read -rp "Proceed? (y/N) " yn
|
||||
[[ "${yn,,}" == "y" ]] || exit 0
|
||||
|
||||
# wipe partitions
|
||||
fdisk /dev/"${SDX}" <<EOF
|
||||
o
|
||||
n
|
||||
p
|
||||
1
|
||||
|
||||
+1G
|
||||
t
|
||||
c
|
||||
n
|
||||
p
|
||||
2
|
||||
|
||||
|
||||
w
|
||||
EOF
|
||||
|
||||
# format
|
||||
mkfs.vfat /dev/"${BOOT}"
|
||||
mkfs.ext4 /dev/"${ROOT}"
|
||||
|
||||
# mount
|
||||
mkdir -p /mnt/boot /mnt/root
|
||||
mount /dev/"${BOOT}" /mnt/boot
|
||||
mount /dev/"${ROOT}" /mnt/root
|
||||
|
||||
# download + extract
|
||||
cd /mnt/root
|
||||
wget -q http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz
|
||||
bsdtar -xpf ArchLinuxARM-rpi-armv7-latest.tar.gz -C /mnt/root
|
||||
sync
|
||||
|
||||
# move boot files
|
||||
mv /mnt/root/boot/* /mnt/boot/
|
||||
|
||||
# cleanup
|
||||
#umount /mnt/boot /mnt/root
|
||||
#rm -rf /mnt/boot /mnt/root
|
||||
|
||||
echo "Done. Insert SD card and boot the Pi."
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
SRC=/var/log/connections/lasts.tcpd
|
||||
DST=/var/log/connections/archive
|
||||
DATE=$(date "+%y%m%d-%H%M")
|
||||
MAXSIZE=$((1024*1024*1024)) # 1 Go
|
||||
|
||||
mkdir -p "$DST"
|
||||
|
||||
# 1️⃣ Archivage IP en .txt
|
||||
find "$SRC" -name "*.log" -mmin -30 \
|
||||
| xargs grepip \
|
||||
> "$DST/connections-$DATE.txt"
|
||||
|
||||
# 2️⃣ Archiver les logs dans un tar.gz
|
||||
ARCHIVE="$DST/logs-$DATE.tar.gz"
|
||||
find "$SRC" -name "*.log" -print0 | tar --null -czf "$ARCHIVE" --remove-files -T -
|
||||
|
||||
# 3️⃣ Vérifier la taille totale des archives et supprimer les plus anciennes si >1 Go
|
||||
total_size=$(du -cb "$DST"/*.tar.gz 2>/dev/null | tail -1 | awk '{print $1}')
|
||||
|
||||
while [ "$total_size" -ge $MAXSIZE ]; do
|
||||
oldest=$(ls -1t "$DST"/*.tar.gz | tail -1)
|
||||
[ -f "$oldest" ] && rm -f "$oldest"
|
||||
total_size=$(du -cb "$DST"/*.tar.gz 2>/dev/null | tail -1 | awk '{print $1}')
|
||||
done
|
||||
|
||||
+6
-1
@@ -1,6 +1,11 @@
|
||||
#!/bin/bash
|
||||
aur ()
|
||||
{
|
||||
git clone https://aur.archlinux.org/$1.git
|
||||
DIR=~/tmp
|
||||
echo "note: ceci est un script maison"
|
||||
mkdir $DIR
|
||||
git clone https://aur.archlinux.org/$1.git $DIR/$1
|
||||
cd $DIR/$1
|
||||
makepkg -si
|
||||
}
|
||||
aur "$@"
|
||||
|
||||
+1
-2
@@ -2,8 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
MACHINE_DIR=${1:$MACHINE_DIR}
|
||||
MACHINE_DIR=${MACHINE_DIR:-"/svr"}
|
||||
MACHINE_DIR="/svr"
|
||||
F_NAME=".bashrc";
|
||||
cd "$MACHINE_DIR/usr/home";
|
||||
commit_if_modified "$F_NAME"
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then
|
||||
echo "Usage: $0 arg1 [arg2] [arg3]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# interactive session check
|
||||
if [ -t 0 ]; then
|
||||
echo -n "Delete existing output files? [y/N]: "
|
||||
read ans
|
||||
case "$ans" in
|
||||
y|Y) rm -f *.school ;;
|
||||
*) echo "Aborted"; exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# process input file
|
||||
while IFS= read -r line; do
|
||||
new_f="${line%.*}.school"
|
||||
f > "$new_f"
|
||||
done < "$FILE"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -55,15 +55,11 @@ def get_feeds(client, profile, tmp_dir=TMP_DIR, save=False, cursor=None):
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Download Bluesky profile posts to JSON")
|
||||
parser.add_argument("handle", help="Bluesky handle (ex: ni-bot.bsky.social)")
|
||||
parser.add_argument("--folder", default=TMP_DIR)
|
||||
parser.add_argument("-d", "--folder", default=TMP_DIR)
|
||||
args = parser.parse_args()
|
||||
|
||||
client = connect()
|
||||
<<<<<<< HEAD
|
||||
profile = get_feeds(client, args.handle, args.folder, cursor=cursor)
|
||||
=======
|
||||
profile = get_feeds(client, args.handle, args.folder)
|
||||
>>>>>>> 01ee0aacb9e93bd6572ab9049f26878733f8bf85
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@ clone ()
|
||||
PROJECT_NAME="$2";
|
||||
git clone --recurse-submodules $URL/$PROFIL_NAME/$PROJECT_NAME.git;
|
||||
else
|
||||
PROFIL_NAME=painpain
|
||||
PROJECT_NAME="$1";
|
||||
git clone --recurse-submodules $URL/$PROFIL_NAME/$PROJECT_NAME.git;
|
||||
fi
|
||||
git clone --recurse-submodules $URL/$PROFIL_NAME/$PROJECT_NAME.git;
|
||||
}
|
||||
clone "$@"
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
expresso ()
|
||||
{
|
||||
DIR="$HOME/perso/thm/interets/jeux/poker";
|
||||
HISTORY="expresso_history.md";
|
||||
DIR="$HOME/perso/jeux/holdem/";
|
||||
HISTORY="historique.md";
|
||||
SCRIPT=expresso_stat.sh;
|
||||
TAIL=${1:-1000};
|
||||
vim + $DIR/$HISTORY;
|
||||
bash $DIR/$SCRIPT $DIR/$HISTORY $TAIL
|
||||
bash $SCRIPT $DIR/$HISTORY $TAIL
|
||||
}
|
||||
expresso "$@"
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
# from vm to make a shared folder
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo """
|
||||
"""
|
||||
echo "cheat sheet: mount -t 9p -o trans=virtio hostshare /mnt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Configurable defaults ---
|
||||
IMG=${1:-disc_alpine.qcow2}
|
||||
SSH=${2:-2222}
|
||||
SHARE=${3:-$PWD/shared}
|
||||
CPUS=${4:-2}
|
||||
SIZE=${5:-16G}
|
||||
RAM=${6:-2G}
|
||||
|
||||
# --- Setup ---
|
||||
mkdir -p "$SHARE"
|
||||
|
||||
# --- Optional install script ---
|
||||
# Drop any file named install.sh in ./share to execute it inside the VM later:
|
||||
# e.g. `bash /mnt/share/install.sh` after mounting
|
||||
|
||||
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-m $RAM \
|
||||
-boot once=d \
|
||||
-drive file=$IMG \
|
||||
-enable-kvm \
|
||||
-display spice-app,show-cursor=on \
|
||||
-nic user,hostfwd=tcp::"${SSH}"-:22
|
||||
|
||||
@@ -4,11 +4,13 @@ set -eux
|
||||
# from vm to make a shared folder
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo """
|
||||
IMG=${1:-disc_alpine.qcow2}
|
||||
SIZE=${2:-16G}
|
||||
RAM=${3:-2G}
|
||||
CPUS=${4:-2}
|
||||
SHARE=${5:-$PWD/share}
|
||||
IMG=${1:-disc_alpine.qcow2}
|
||||
SSH=${2:2223}
|
||||
SHARE=${3:-$PWD/share}
|
||||
CPUS=${4:-2}
|
||||
SIZE=${5:-16G}
|
||||
RAM=${6:-2G}
|
||||
GITEA=${7:-3000}
|
||||
"""
|
||||
echo "cheat sheet: mount -t 9p -o trans=virtio hostshare /mnt"
|
||||
exit 1
|
||||
@@ -16,10 +18,12 @@ fi
|
||||
|
||||
# --- Configurable defaults ---
|
||||
IMG=${1:-disc_alpine.qcow2}
|
||||
SIZE=${2:-16G}
|
||||
RAM=${3:-2G}
|
||||
SSH=${2:-2223}
|
||||
SHARE=${3:-$PWD/share}
|
||||
CPUS=${4:-2}
|
||||
SHARE=${5:-$PWD/share}
|
||||
SIZE=${5:-16G}
|
||||
RAM=${6:-2G}
|
||||
GITEA=${7:-3000}
|
||||
|
||||
# --- Setup ---
|
||||
mkdir -p "$SHARE"
|
||||
@@ -37,6 +41,6 @@ qemu-system-x86_64 \
|
||||
-device virtio-vga \
|
||||
-enable-kvm \
|
||||
-display default,show-cursor=on \
|
||||
-nic user,hostfwd=tcp::2222-:22 \
|
||||
-nic user,hostfwd=tcp::"${SSH}"-:22,hostfwd=tcp::"${GITEA}"-:3000 \
|
||||
-virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare
|
||||
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
NB_LINES=${1:=5}
|
||||
for ((i=0;i<NB_LINES;i++))
|
||||
do
|
||||
history -d $(history | tail -n 1 | awk '{print $1}')
|
||||
done
|
||||
history -w
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/home/painpain/Desktop/idea-IU-253.30387.90/bin/idea
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
journal-perso ()
|
||||
{
|
||||
. . refresh_time;
|
||||
. refresh_time;
|
||||
DIR_ORIGINAL=$PWD;
|
||||
DIR=$PERSO_DIR;
|
||||
DATE_DIR="$YEAR/$MONTH/$DAY";
|
||||
@@ -21,6 +21,7 @@ journal-perso ()
|
||||
else
|
||||
return 1;
|
||||
fi;
|
||||
mkdir -p $DIR
|
||||
F_NAME+=".md";
|
||||
cd $DIR;
|
||||
PATH_="${DATE_DIR}/${LN_DIR}";
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
NAME+=$(dmesg | tail | grep -o sd[a-z] | tail -1)
|
||||
NAME+=1
|
||||
DEV=/dev/${NAME}
|
||||
MNT_PT=/mnt/$NAME
|
||||
BLOCK=crypt_${NAME}
|
||||
|
||||
echo "mount dev: $DEV at $MNT_PT"
|
||||
cryptsetup luksOpen $DEV $BLOCK
|
||||
mkdir $MNT_PT
|
||||
mount $/dev/mapper/$BLOCK $MNT_PT
|
||||
cd $MNT_PT
|
||||
|
||||
exit 0
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
nvim ~/.conf/nvim
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
ping -c1 9.9.9.9
|
||||
ping -c1 9.9.9.9 | grep transmit
|
||||
ping -c1 wikipedia.org | grep transmit
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
|
||||
if [ "$#" -lt 1 ] ; then
|
||||
echo "Usage: $0 arg1 [arg2] [arg3]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for DIR in "$@" ; do
|
||||
cp -r $DIR/* .
|
||||
cp -r $DIR/.* .
|
||||
mv $DIR /tmp
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
root="${1:-.}"
|
||||
|
||||
find "$root" -type f -print0 |
|
||||
while IFS= read -r -d '' file; do
|
||||
printf -- "---\n%s\n-\n" "$file"
|
||||
cat -- "$file"
|
||||
printf "\n"
|
||||
done
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Ensure exrex is installed
|
||||
try:
|
||||
import exrex
|
||||
except ImportError:
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", "exrex"])
|
||||
import exrex
|
||||
|
||||
import argparse
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Generate all possibilities from a regex")
|
||||
parser.add_argument("regex", type=str, help="Regex pattern (finite)")
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
for match in exrex.generate(args.regex):
|
||||
print(match)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
nvim $@
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then
|
||||
echo "Usage: $0 arg1 [arg2] [arg3]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VPS=${1:-"$IAMUTOPIST"}
|
||||
USER=${2:-"root"}
|
||||
VPS_PORT=${3:-"443"}
|
||||
HOST_PORT=${4:-"3000"}
|
||||
|
||||
echo """
|
||||
runs:
|
||||
ssh -N -R $VPS_PORT:localhost:$HOST_PORT $USER@$VPS
|
||||
"""
|
||||
|
||||
ssh -N -R $VPS_PORT:localhost:$HOST_PORT $USER@$VPS
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
vrc ()
|
||||
{
|
||||
SOURCE="$HOME/.vimrc";
|
||||
F_NAME=".bash_aliases";
|
||||
FILE="$(find -O3 $HOME -name $F_NAME 2> /dev/null | head -n 1)";
|
||||
SOURCE="/home/.bashrc";
|
||||
F_NAME=".vimrc";
|
||||
FILE=/home/$F_NAME
|
||||
F_PATH="$(dirname $FILE)";
|
||||
cd "$F_PATH";
|
||||
commit_if_modified "$F_NAME";
|
||||
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Wrapper that always uses Firefox cookies for YouTube
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <url> [extra yt-dlp args...]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Change profile name if needed (e.g. default-release, yourprofile.default)
|
||||
BROWSER="firefox"
|
||||
PROFILE="default-release" # or leave empty to let yt-dlp auto-detect
|
||||
|
||||
if [ -n "$PROFILE" ]; then
|
||||
yt-dlp --cookies-from-browser "${BROWSER}:${PROFILE}" "$@"
|
||||
else
|
||||
yt-dlp --cookies-from-browser "$BROWSER" "$@"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user