Merge branch 'main' of github.com:nidionis/svr

This commit is contained in:
dangerboot
2026-03-08 09:39:25 +01:00
47 changed files with 402 additions and 248 deletions
+7 -3
View File
@@ -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 \
+60
View File
@@ -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."
+27
View File
@@ -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
View File
@@ -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
View File
@@ -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"
-25
View File
@@ -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
+1 -5
View File
@@ -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
+2
View File
@@ -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
View File
@@ -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 "$@"
+36
View File
@@ -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
+8
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
/home/painpain/Desktop/idea-IU-253.30387.90/bin/idea
+2 -1
View File
@@ -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}";
-1
View File
@@ -12,4 +12,3 @@ mount $DEV $MNT_PT
cd $MNT_PT
exit 0
+15
View File
@@ -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
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/bash
nvim ~/.conf/nvim
+5 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
+26
View File
@@ -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
View File
@@ -0,0 +1,3 @@
#!/usr/bin/bash
nvim $@
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/bash
nvim $@
+18
View File
@@ -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
View File
@@ -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
View File
@@ -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
+1
View File
@@ -13,6 +13,7 @@ LOG_CONN_DIR=/var/log/tcpd
LOG_CONN=$LOG_CONN_DIR/lasts.log
NET_STATUS=/tmp/status.txt
SSH=177
IAMUTOPIST=128.65.199.189
JOURNAL_DIR=$HOME/journal
PERSO_DIR=$HOME/perso
-5
View File
@@ -1,13 +1,8 @@
#%PAM-1.0
auth requisite pam_nologin.so
auth include system-local-login
auth optional pam_gnome_keyring.so
account include system-local-login
session include system-local-login
session optional pam_gnome_keyring.so auto_start
password include system-local-login
+6
View File
@@ -0,0 +1,6 @@
#%PAM-1.0
auth required pam_unix.so try_first_pass
account required pam_unix.so
password required pam_unix.so
session required pam_unix.so
+1 -3
View File
@@ -1,5 +1,3 @@
nameserver 1.1.1.1
nameserver 0.0.0.0
nameserver 8.26.56.26
nameserver 208.67.222.222
nameserver 209.244.0.3
Regular → Executable
-44
View File
@@ -1,44 +0,0 @@
# This file is part of systemd. -> systemctl enable --now systemd-resolved
#
# systemd 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.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/resolved.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
#
# See resolved.conf(5) for details.
[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
DNS=1.1.1.1 2606:4700:4700::1111 2606:4700:4700::1001
# Quad9: 9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
FallbackDNS=185.253.5.0 2a0f:fc80:: 2a0f:fc81::
#
# Using DNS= configures global DNS servers and does not suppress link-specific
# configuration. Parallel requests will be sent to per-link DNS servers
# configured automatically by systemd-networkd.service(8), NetworkManager(8), or
# similar management services, or configured manually via resolvectl(1). See
# resolved.conf(5) and systemd-resolved(8) for more details.
#DNS=
#FallbackDNS=9.9.9.9#dns.quad9.net 2620:fe::9#dns.quad9.net 1.1.1.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 8.8.8.8#dns.google 2001:4860:4860::8888#dns.google
#Domains=
DNSSEC=allow-downgrade
DNSOverTLS=yes
MulticastDNS=yes
LLMNR=yes
Cache=yes
CacheFromLocalhost=no
DNSStubListener=yes
#DNSStubListenerExtra=
ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no
#StaleRetentionSec=0
#RefuseRecordTypes=
+29
View File
@@ -0,0 +1,29 @@
# This file is part of systemd.
#
# systemd 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.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/sleep.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/sleep.conf' to display the full config.
#
# See systemd-sleep.conf(5) for details.
[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
SuspendState=freeze #mem standby freeze
HibernateMode=platform # shutdown
#MemorySleepMode=
#HibernateDelaySec=
#HibernateOnACPower=yes
#SuspendEstimationSec=60min
+4 -3
View File
@@ -1,10 +1,11 @@
[Unit]
Description=watch connections
After=network-online.target
Description=TCP connections logger
After=network.target
[Service]
ExecStart=/bin/bash /etc/systemd/system/tcpd.sh
Type=simple
ExecStart=/usr/bin/tcpdump
Restart=always
[Install]
WantedBy=multi-user.target
+11 -1
View File
@@ -24,9 +24,19 @@ alias val="valgrind --leak-check=full --show-leak-kinds=all"
alias mvj='rsync -aH --remove-source-files'
alias cpj='rsync -aH'
alias git_light="git filter-repo --strip-blobs-bigger-than 10M"
alias src="source ~/.bashrc"
alias s="sudo -E"
function src() {
source $HOME/.bashrc || true
d="$PWD"; while [ "$d" != "/" ]; do
for a in "$d/bin/activate" "$d/.env/bin/activate"; do
[ -f $a ] && echo "found at $a" && . "$a" && break 2
done
d=$(dirname "$d")
done
}
##convert mp3 to wav
#to_wav () {
# OUTDIR_NAME="wav_files"
+5 -10
View File
@@ -4,9 +4,9 @@
if [ -f /etc/env ]; then
set -a
. /etc/env
set +a
set -a
. /etc/env
set +a
fi
set -o vi
@@ -104,7 +104,7 @@ RESET_COLOR="$NO_COLOR"
export GIT_EDITOR=vim
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
PS1="\n${DATE_COLOR}\D{%y%m%d}${RESET_COLOR}-${TIME_COLOR}\t${RESET_COLOR}-${USER_COLOR}\u${RESET_COLOR}@${HOST_COLOR}\H${RESET_COLOR}-${DIR_COLOR}\w${RESET_COLOR}\n=> "
PS1="\n\n${DATE_COLOR}\D{%y%m%d}${RESET_COLOR}-${TIME_COLOR}\t${RESET_COLOR}-${USER_COLOR}\u${RESET_COLOR}@${HOST_COLOR}\H${RESET_COLOR}-${DIR_COLOR}\w${RESET_COLOR}\n=> "
export HISTCONTROL=ignorespace
@@ -122,21 +122,16 @@ export AWK_GREP_KEY="'{
}
}'"
#ctags -R .
bind -f /home/.inputrc
if [ -f /home/.bash_aliases ]; then
. /home/.bash_aliases
. /home/.bash_aliases
fi
# permet les accents
setxkbmap us -variant intl
source $PY_ENV/bin/activate
#envsubst < ${MACHINE_PATH}/dotfiles/ssh/config.template > ~/.ssh/config
#export PATH=~/.npm-global/bin:$PATH
+3 -2
View File
@@ -87,8 +87,7 @@ autocmd BufNewFile *.c 0r ./.vim/templates/template.c
set mouse=a
inoremap {{ {}<ESC>O
inoremap {;{ ;}<ESC>O
inoremap { {<CR>}<Esc>O
:nnoremap <Space> @q
@@ -102,3 +101,5 @@ set tags=./tags;,tags;
syntax on
set tags=./tags;/
set smartindent