rebasing .git

This commit is contained in:
journal_froid
2026-01-23 09:59:19 +01:00
parent 199b9429ad
commit 1d4435089f
60 changed files with 382 additions and 154 deletions
Executable
+25
View File
@@ -0,0 +1,25 @@
#!/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
Regular → Executable
View File
Regular → Executable
+2
View File
@@ -22,3 +22,5 @@ BIN=$MACHINE_DIR/usr/bin
SBIN_DIR=$MACHINE_DIR/usr/sbin
BIN_DIR=$BIN
PY_ENV=$BIN/py-env
VPS=83.228.219.61
Regular → Executable
View File
+2
View File
@@ -0,0 +1,2 @@
Gtd5u0nRC3vf1oRt
RUWJhKHulxLjfg8jDqvDncC5DMq6lZRE
View File
View File
View File
View File
View File
View File
View File
View File
View File
+13
View File
@@ -0,0 +1,13 @@
#%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
Regular → Executable
+1
View File
@@ -1,4 +1,5 @@
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
+3 -3
View File
@@ -18,9 +18,9 @@
[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
DNS=1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001 #cloudflare-dns.com
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=193.110.81.0 185.253.5.0 2a0f:fc80:: 2a0f:fc81:: #dns0.eu
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
@@ -30,7 +30,7 @@ FallbackDNS=193.110.81.0 185.253.5.0 2a0f:fc80:: 2a0f:fc81:: #dns0.eu
#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=yes
DNSSEC=allow-downgrade
DNSOverTLS=yes
MulticastDNS=yes
LLMNR=yes
-1
View File
@@ -4,7 +4,6 @@ After=network-online.target
[Service]
ExecStart=/bin/bash /etc/systemd/system/tcpd.sh
After=tcpd-bkup.service
Type=simple
[Install]
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=backups tcpd log file, keeping ip adresses only
[Service]
ExecStart=/bin/bash /etc/systemd/system/tcpd_bkup.sh
Restart=on-failure
RestartSec=121s
Type=oneshot
[Install]
WantedBy=multi-user.target
+9 -8
View File
@@ -1,21 +1,22 @@
#!/usr/bin/bash
#!/bin/bash
#run from crontab
. /home/.bashrc
[ -f "$LOG_CONN" ] || exit 0
. refresh_time
STATUS=ronron
STATUS=network.conns
if [ -f $NET_STATUS ] ; then
STATUS=$(cat $NET_STATUS)
fi
DIR=$LOG_CONN_DIR/$STATUS
DIR="$LOG_CONN_DIR/$STATUS"
mkdir -p $DIR
grepip $LOG_CONN > $DIR/${DATE}_${TIME}.conn
mv -f $LOG_CONN $LOG_CONN_DIR/prev.log
grepip "$LOG_CONN" > "$DIR/${DATE}_${TIME}.conn"
mv -f "$LOG_CONN" "$LOG_CONN_DIR/prev.log"
systemctl restart tcpd
exit 0
+10
View File
@@ -0,0 +1,10 @@
[Unit]
Description=Run tcpd_bkup.service every 2 minutes
[Timer]
OnBootSec=2min
OnUnitActiveSec=2min
Persistent=true
[Install]
WantedBy=timers.target
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
View File
View File
View File
View File
View File
View File
Regular → Executable
View File
+125
View File
@@ -0,0 +1,125 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
#define BUFFER_CHUNK 4096
/* ---------------------- URL PARSING ---------------------- */
void parse_url(const char *input, char *host, size_t hsz, char *path, size_t psz)
{
const char *slash = strchr(input, '/');
if (slash) {
size_t host_len = slash - input;
if (host_len >= hsz) host_len = hsz - 1;
strncpy(host, input, host_len);
host[host_len] = '\0';
snprintf(path, psz, "%s", slash);
} else {
snprintf(host, hsz, "%s", input);
snprintf(path, psz, "/");
}
}
/* ---------------------- CONNECT TO HOST ---------------------- */
int connect_to_host(const char *host)
{
struct addrinfo hints = {0}, *res;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
getaddrinfo(host, "80", &hints, &res);
int sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (sock < 0) {
perror("socket");
freeaddrinfo(res);
return -1;
}
if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
perror("connect");
close(sock);
freeaddrinfo(res);
return -1;
}
freeaddrinfo(res);
return sock;
}
/* ---------------------- SEND HTTP GET REQUEST ---------------------- */
int send_request(int sock, const char *host, const char *path)
{
char req[1024];
snprintf(req, sizeof(req),
"GET %s HTTP/1.0\r\n"
"Host: %s\r\n"
"User-Agent: basic-c-client\r\n"
"\r\n",
path, host);
return send(sock, req, strlen(req), 0);
}
/* ---------------------- DOWNLOAD RESPONSE ---------------------- */
char *download_response(int sock, size_t *out_size)
{
char *filedata = NULL;
*out_size = 0;
char buffer[BUFFER_CHUNK];
ssize_t bytes;
while ((bytes = recv(sock, buffer, sizeof(buffer), 0)) > 0) {
char *newbuf = realloc(filedata, *out_size + bytes + 1);
if (!newbuf) {
fprintf(stderr, "Out of memory\n");
free(filedata);
return NULL;
}
filedata = newbuf;
memcpy(filedata + *out_size, buffer, bytes);
*out_size += bytes;
filedata[*out_size] = '\0';
}
return filedata;
}
/* ---------------------- MAIN PROGRAM ---------------------- */
int main(int argc, char **argv)
{
if (argc < 2) {
fprintf(stderr, "Usage: %s <host/path>\n", argv[0]);
return 1;
}
char host[256];
char path[512];
parse_url(argv[1], host, sizeof(host), path, sizeof(path));
int sock = connect_to_host(host);
if (sock < 0) return 1;
send_request(sock, host, path);
size_t filesize;
char *filedata = download_response(sock, &filesize);
close(sock);
if (!filedata) return 1;
printf("Received %zu bytes:\n\n%s\n", filesize, filedata);
f = open(argv[2], "w");
write(f, filedata, filesize);
free(filedata);
return 0;
}
View File
-63
View File
@@ -1,63 +0,0 @@
#!/bin/bash
set -eux
ISO_URL="https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/x86_64/alpine-virt-3.22.2-x86_64.iso"
# from vm to make a shared folder
if [ $# -lt 1 ] ; then
echo """
ISO=${1:-$(basename $ISO_URL)}
IMG=${2:-disc_alpine.qcow2}
SIZE=${3:-16G}
RAM=${4:-2G}
CPUS=${5:-2}
SHARE=${6:-$PWD/share}
"""
echo "cheat sheet: mount -t 9p -o trans=virtio hostshare /mnt"
fi
# --- Configurable defaults ---
ISO=${1:-$(basename $ISO_URL)}
IMG=${2:-disc_alpine.qcow2}
SIZE=${3:-16G}
RAM=${4:-2G}
CPUS=${5:-2}
SHARE=${6:-$PWD/share}
# --- Setup ---
mkdir -p "$SHARE"
echo "iso = $ISO"
[ -f "$ISO" ] || wget "$ISO_URL"
[ -f "$IMG" ] || qemu-img create -o nocow=on -f qcow2 "$IMG" "$SIZE"
# --- 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 \
-cdrom $ISO \
-drive file=$IMG \
-device virtio-vga \
-enable-kvm \
-display default,show-cursor=on \
-nic user,hostfwd=tcp::2222-:22 \
-virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare
## --- Run QEMU with graphics + shared folder ---
#qemu-system-x86_64 \
# -enable-kvm \
# -m "$RAM" \
# -cpu host \
# -smp "$CPUS" \
# -boot d \
# -cdrom "$ISO" \
# -drive file="$IMG",format=qcow2 \
# -device virtio-vga \
# -display default,show-cursor=on \
# -nic user,hostfwd=tcp::2222-:22 \
# -virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare
View File