From 6a8b7082b9bf638c4901a9d3723f91e6764bf60f Mon Sep 17 00:00:00 2001 From: xf0r3m Date: Sat, 18 Apr 2026 19:16:52 +0200 Subject: [PATCH 1/1] =?utf8?q?Przes=C5=82anie=20plik=C3=B3w=20na=20repozyt?= =?utf8?q?orium.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++ immudex-cdrip | 148 ++++++++++++++++++++++++++++ immudex-create-media | 137 ++++++++++++++++++++++++++ immudex-crypt | 202 ++++++++++++++++++++++++++++++++++++++ immudex-meteo | 47 +++++++++ immudex-motd/immudex-motd | 107 ++++++++++++++++++++ immudex-motd/motd.conf | 18 ++++ immudex-pl | 140 ++++++++++++++++++++++++++ immudex-shoutcasts | 162 ++++++++++++++++++++++++++++++ immudex-ytplay | 131 ++++++++++++++++++++++++ 10 files changed, 1098 insertions(+) create mode 100644 README.md create mode 100755 immudex-cdrip create mode 100755 immudex-create-media create mode 100755 immudex-crypt create mode 100755 immudex-meteo create mode 100755 immudex-motd/immudex-motd create mode 100644 immudex-motd/motd.conf create mode 100755 immudex-pl create mode 100755 immudex-shoutcasts create mode 100755 immudex-ytplay diff --git a/README.md b/README.md new file mode 100644 index 0000000..3817b0b --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +![Image](https://i.ibb.co/NxtyJ3T/immudex2.png) + +# immudex-tools + +Scripts from immudex - could be useful in Debian. + diff --git a/immudex-cdrip b/immudex-cdrip new file mode 100755 index 0000000..8ef6186 --- /dev/null +++ b/immudex-cdrip @@ -0,0 +1,148 @@ +#!/bin/bash + +function XMLScrap() { + echo -n $(grep -o "<${1}>.*" $2 \ + | sed "s,<${1}>,," \ + | sed "s,,," \ + | sed 's,&,and,g'); +} + +function help() { + echo "immudex-cdrip it's a bash script for collect audio tracks from Audio CD's."; + echo "Script apart form ripping Audio CD's, reads metadata, check it on music"; + echo "databases and creates properly named directories and audio files."; + echo; + echo "Usage: immudex-cdrip [--rip-only] [--get-disc-info] [--rip-n-rename] [--help] [--version]"; + echo; + echo "Options:"; + echo " --rip-only Rips audio tracks from Audio CD, without quering CDIndex (MusicBrainz) database."; + echo " --get-disc-info Getting info from CDIndex (MusicBrainz) database about Audio CD without ripping."; + echo " --rip-n-rename Rips audio tracks from Audio CD, create Artist/Album folders and rename tracks according to data get CDIndex (MusicBrainz) database (normal usage)."; + echo " --help Print this message."; + echo " --version Print information about version, author and copyrights."; + echo; + echo "Examples:"; + echo " immudex-cdrip Print this message"; + echo " immudex-cdrip --get-disc-info Check is in MusicBrainz DB, are there any data about puted CD in drive."; + echo " Could be useful with less popular artists."; + echo " immudex-cdrip --rip-n-rename Rips Audio CD and names dirs and files with MusicBrainz data."; + echo; + echo "Report bugs to "; +} + +function version() { + echo "immudex-cdrip 1.0"; + echo; + echo "Copyright (C) 2026 morketsmerke.org"; + echo "This is free software; see the source for copying conditions. There is NO"; + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; + echo; + echo "Written by xf0r3m."; +} + +function multipleArtistDisc() { + + FILE="$1"; + ARTIST="VA"; + ALBUM=$(XMLScrap "Title" $FILE); + NUMTRACKS=$(XMLScrap "NumTracks" $FILE); + TRACKPATH="${ARTIST} - ${ALBUM}"; + + mkdir -vp "${TRACKPATH}"; + + i=1; + while [ $i -le $NUMTRACKS ]; do + artist=$(grep -o ".*" $FILE \ + | sed -n "${i}p" \ + | sed 's,,,' \ + | sed 's,,,'); + + trackName=$(grep -o ".*" $FILE \ + | sed -n "${i}p" \ + | sed 's,,,' \ + | sed 's,,,'); + + if [ $i -lt 10 ]; then + trackNumber="0${i}"; + else + trackNumber=${i}; + fi + + audioFilename="audio_${trackNumber}.wav"; + infFilename=$(echo $audioFilename | sed 's/wav/inf/'); + + mv -v $audioFilename "${TRACKPATH}/${trackNumber}. ${artist} - ${trackName}.wav"; + rm -v ${infFilename}; + i=$(expr $i + 1); + done + + rm -v audio.cddb; + rm -v ${FILE}; +} + +#if [ ! -x /usr/bin/cdda2wav ]; then +# exit 1; +#fi + +if [ "$1" ] && [ "$1" = "--rip-only" ]; then + cdda2wav -vall cddb=-1 speed=4 -paranoia paraopts=no-verify -B -D /dev/sr0; + exit 0; +fi + +if [ "$1" ] && [ "$1" = "--get-disc-info" ]; then + cdda2wav -J -D /dev/sr0; + exit 0; +fi + +if [ "$1" ] && [ "$1" = "--rip-n-rename" ]; then + cdda2wav -vall cddb=1 speed=4 -paranoia paraopts=no-verify -B -D /dev/sr0; + + FILE="audio.cdindex"; + + if $(grep -q '' $FILE); then + multipleArtistDisc $FILE; + else + ARTIST=$(XMLScrap "Artist" $FILE); + ALBUM=$(XMLScrap "Title" $FILE); + NUMTRACKS=$(XMLScrap "NumTracks" $FILE); + TRACKPATH="${ARTIST}/${ALBUM}"; + + mkdir -vp "${TRACKPATH}"; + + i=1; + while [ $i -le $NUMTRACKS ]; do + trackName=$(grep -o ".*" $FILE \ + | sed -n "${i}p" \ + | sed 's,,,' \ + | sed 's,,,'); + + if [ $i -lt 10 ]; then + audioFilename="audio_0${i}.wav"; + trackNumber="0${i}"; + else + audioFilename="audio_${i}.wav"; + trackNumber="${i}"; + fi + infFilename=$(echo "$audioFilename" | sed 's/wav/inf/'); + mv -v $audioFilename "${TRACKPATH}/${trackNumber}. ${ARTIST} - ${trackName}.wav"; + rm -v $infFilename; + i=$(expr $i + 1); + done + + rm -v audio.cddb; + rm -v audio.cdindex; + fi + exit 0; +fi + +if [ "$1" ] && [ "$1" = "--help" ]; then + help; + exit 0; +fi + +if [ "$1" ] && [ "$1" = "--version" ]; then + version; + exit 0; +fi + +help; diff --git a/immudex-create-media b/immudex-create-media new file mode 100755 index 0000000..1441f9d --- /dev/null +++ b/immudex-create-media @@ -0,0 +1,137 @@ +#!/bin/bash + +GREEN="\e[32m"; +YELLOW="\e[33m"; +ENDCOLOR="\e[0m"; + +function help() { + echo "immudex-create-media it's script used for write iso image to usb drive."; + echo "Script writes .iso file to usb stick - make it then bootable. This" + echo "script prepare usb disks for 32-bit EFI systems." + echo "Superuser (root) privileges are required."; + echo; + echo "Usage: immudex-create-media [--help] [--version] [--i386-efi --disk=usb_disk --isofile=immudex.iso] [--nuke --disk=usb_disk] --disk=usb_disk --isofile=file.iso"; + echo; + echo "Options:"; + echo " --disk=/dev/sdX Indicates disk device."; + echo " --isofile=file.iso Indicates iso file."; + echo " --i386-efi --disk=/dev/sdX immudex.iso Creating 32-bit EFI bootable usb drive with iso image. (Compatibile with immudex images only.)"; + echo " --nuke --disk=/dev/sdX Write 0's to 1st megabyte of disk, wiping partition table."; + echo " --help Print this message."; + echo " --version Print information about version, author and copyrights."; + echo; + echo "Exmaples:"; + echo " immudex-create-media Print this message."; + echo " immudex-create-media --disk=/dev/sdX --isofile=file.iso Writes iso file to usb stick, made it bootable."; + echo " immudex-create-media --i386-efi --disk=/dev/sdX --isofile=immudex.iso Create 32-bit EFI bootable usb stick with immudex."; + echo " immudex-create-media --nuke --disk=/dev/sdX Writes first MB with 0's, deleting partition table"; + echo; + echo "Report bugs to "; +} + +function version() { + echo "immudex-create-media 1.0"; + echo; + echo "Copyright (C) 2026 morketsmerke.org"; + echo "This is free software; see the source for copying conditions. There is NO"; + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; + echo; + echo "Written by xf0r3m."; +} + +if [ $UID -ne 0 ]; then + echo "Permission denied!"; + help; + exit 1; +fi + +if [ "$1" ] && [ "$1" = "--help" ]; then help; exit 0; fi +if [ "$1" ] && [ "$1" = "--version" ]; then version; exit 0; fi + +if [ "$1" ] && [ "$1" = "--i386-efi" ]; then target="i386-efi"; shift; fi +if [ "$1" ] && [ "$1" = "--nuke" ]; then target="nuke"; shift; fi +if [ "$1" ] && [ "$(echo $1 | cut -d "=" -f 1)" = "--disk" ]; then + disk=$(echo $1 | cut -d "=" -f 2); shift; +else + help; + exit 1; +fi +if [ ! "$target" ] || [ "$target" != "nuke" ]; then + if [ "$1" ] && [ "$(echo $1 | cut -d "=" -f 1)" = "--isofile" ]; then + iso=$(echo $1 | cut -d "=" -f 2); + else + help; + exit 1; + fi +fi + +if [ "$target" = "i386-efi" ]; then + echo -n "Writing zeros to 1st megabyte on disk..."; + dd if=/dev/zero bs=1M of=$disk count=1 > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Creating MS-DOS partitionig scheme on disk..."; + parted $disk mklabel msdos > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Creating FAT-32 partition..."; + parted $disk mkpart primary fat32 1 100%Free > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Creating VFAT filesystem on partition..."; + mkfs.vfat ${disk}1 > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Creating /mnt/usb directory..."; + mkdir /mnt/usb > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; + else echo -e "[${YELLOW}Directory exist!${ENDCOLOR}]"; fi + + echo -n "Mounting VFAT partition on /mnt/usb..."; + mount ${disk}1 /mnt/usb > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Instalation GRUB on disk..."; + grub-install --target=i386-efi --efi-directory=/mnt/usb --boot-directory=/mnt/usb/boot --bootloader-id=boot --removable > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Creating /mnt/iso directory..."; + mkdir /mnt/iso > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; + else echo -e "[${YELLOW}Directory exist!${ENDCOLOR}]"; fi + + echo -n "Mounting iso file on /mnt/iso..."; + mount $iso /mnt/iso > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Copying grub config files to the disk..."; + cp /mnt/iso/boot/grub/font.pf2 /mnt/usb/boot/grub > /dev/null 2>&1; + cp /mnt/iso/boot/grub/grub.cfg /mnt/usb/boot/grub > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Copying immudex files to the disk..."; + cp -r /mnt/iso/live /mnt/usb > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Creating empty DEBIAN file..."; + touch /mnt/usb/DEBIAN > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Umounting all mounted filesystems..."; + umount /mnt/usb /mnt/iso > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + +elif [ "$target" = "nuke" ]; then + echo -n "Writing zeros to 1st megabyte on disk..."; + dd if=/dev/zero bs=1M of=$disk count=1 > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + +else + echo -n "Writing zeros to 1st megabyte on disk..."; + dd if=/dev/zero bs=1M of=$disk count=1 > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi + + echo -n "Writing iso image to the disk..." + dd if=$iso bs=1M of=$disk > /dev/null 2>&1; + if [ $? -eq 0 ]; then echo -e "[${GREEN}OK${ENDCOLOR}]"; fi +fi diff --git a/immudex-crypt b/immudex-crypt new file mode 100755 index 0000000..38fd47c --- /dev/null +++ b/immudex-crypt @@ -0,0 +1,202 @@ +#!/bin/bash + +function help() { + + echo "immudex-crypt is script used for listing, open, close and create crypt_LUKS partitions."; + echo "Script creates 'immudex-crypt' mount points, every mount point end up with 'index'."; + echo "Index is order number of opening crypt_LUKS devices via 'immudex-crypt' The first"; + echo "opened device will have index equal 0, second = 1, and so on and on."; + echo "Superuser (root) privileges are required."; + echo; + echo "Usage: immudex-crypt [--list] [--create=/dev/partition] [--open=crypt_LUKS_device] [--close=index] [--help] [--version]"; + echo; + echo "Options:"; + echo " --list Prints list of opened and available crypt_LUKS devices."; + echo " --create=/dev/partition Preparing device for crypt_LUKS."; + echo " --open=/dev/crypt_LUKS_device Opening and mount crypt_LUKS device (create mount point, if not exist)."; + echo " --close=index Unmounting and close opened crypt_LUKS devices."; + echo " --help Prints this message."; + echo " --version Print information about version, author and copyrights."; + echo; + echo "Examples:"; + echo " immudex-crypt --list List available crypt_LUKS devices in the system."; + echo " immudex-crypt --create=/dev/sdX Create crypt_LUKS device from given partition."; + echo " immudex-crypt --open=/dev/sdX Open given crypt_LUKS device (with mounting file system, of course)."; + echo " immudex-crypt --close=0 Close first opened crypt_LUKS device in the system."; + echo; + echo "Report bugs to "; +} + +function version() { + echo "immudex-crypt 1.0"; + echo; + echo "Copyright (C) 2026 morketsmerke.org"; + echo "This is free software; see the source for copying conditions. There is NO"; + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; + echo; + echo "Written by xf0r3m."; +} + +function list() { + + mapperDeviceList=$(ls /dev/mapper | grep 'immudex-*' | awk '{printf $1" "}'); + + echo "=============================================================="; + echo -e "Opened devices:"; + echo "=============================================================="; + echo -e "Device:\t\tMapper name:\t\tMount point:"; + + if [ "$mapperDeviceList" ]; then + for dmDevice in $mapperDeviceList; do + if cryptsetup status /dev/mapper/${dmDevice} > /dev/null 2>&1; then + mountPoint=$(df --output=source,target /dev/mapper/${dmDevice} | tail -n 1 | awk '{printf $2}'); + device=$(cryptsetup status /dev/mapper/${dmDevice} | grep "device" | awk '{printf $2}'); + if [ "$mountPoint" ] && [ "$mountPoint" != "/dev" ]; then + echo -e "$device\t /dev/mapper/${dmDevice}\t$mountPoint"; + else + echo -e "$device\t /dev/mapper/${dmDevice}\tNot mounted"; + fi + fi + done + else + echo -e "No opened crypt devices was found"; + fi + echo "=============================================================="; + + luksDevicesList=$(blkid | grep 'LUKS' | cut -d ":" -f 1 | awk '{printf $1" "}'); + + echo "=============================================================="; + echo -e "crypt_LUKS devices:"; + echo "=============================================================="; + echo -e "Device:\t\t\tSize:"; + + if [ "$luksDevicesList" ]; then + for lDevice in $luksDevicesList; do + lDeviceSize=$(lsblk | grep "$(basename $lDevice)" | sed -n '1p' | awk '{printf $4}'); + echo -e "$lDevice\t\t$lDeviceSize"; + done + else + echo "No crypt device was found"; + fi + echo "=============================================================="; +} + +function open() { + + if [ $# -lt 1 ]; then help; exit 1; + else + index=$(ls --hide=control /dev/mapper | grep "immudex-crypt" | grep -o "[0-9]*$"| tail -1); + if [ "$index" ]; then + index=$((index + 1)); + else + index=0; + fi + cryptsetup open $1 immudex-crypt${index}; + mkdir -p /media/${USER}/immudex-crypt${index}; + lastField=$(ls -l /dev/mapper/immudex-crypt${index} | grep -o ' ' | wc -l); + dmDevice=$(ls -al /dev/mapper/immudex-crypt${index} | cut -d " " -f ${lastField}- | cut -d "/" -f2); + if ! $(file -s /dev/${dmDevice} | grep -q 'ext4'); then + echo "Could not determine filesystem of unlocked device."; + echo -n "Format this device to ext4? (y/n): " + read format; + if [ "$format" = "y" ]; then + mkfs.ext4 /dev/mapper/immudex-crypt${index}; + else + echo "Refuse to mount."; + cryptsetup close immudex-crypt${index}; + exit 1; + fi + fi + mount /dev/mapper/immudex-crypt${index} /media/${USER}/immudex-crypt${index}; + if [ ! -e /ic${index} ]; then + ln -s /media/${USER}/immudex-crypt${index} /ic${index}; + fi + fi + +} + +function close() { + + if [ $# -lt 1 ]; then help; exit 1; + else + if [ $1 -ge 0 ] 2> /dev/null; then + cryptfsName="immudex-crypt${1}"; + elif echo $1 | grep -q 'ic'; then + cryptfsName="immudex-crypt$(echo $1 | grep -o '[0-9]')"; + else + cryptfsName=$1; + fi + if cryptsetup status /dev/mapper/${cryptfsName} > /dev/null 2>&1; then + mountPoint=$(df --output=source,target /dev/mapper/${cryptfsName} | tail -1 | awk '{printf $2}'); + if [ "$mountPoint" ] && [ "$mountPoint" != "/dev" ]; then + umount -R $mountPoint; + cryptsetup close ${cryptfsName}; + else + cryptsetup close ${cryptfsName}; + fi + else + echo "Given devices isn't opened crypt device or it was closed before"; + fi + fi +} + +function create() { + if [ $# -lt 1 ]; then help; exit 1; + else + cryptsetup -y -v luksFormat $1; + fi +} + +function set_ownership(){ + if [ $# -lt 1 ]; then help; exit 1; + else + mountPoint=$(list | grep "$USER" | grep "$1" | awk '{printf $3}') + owner=$(stat -c %u $mountPoint); + if [ $owner -eq $RUID ]; then + if id $USER | grep -q $RUID; then + echo "User $USER is already owner of $mountPoint"; + fi + else + chown ${USER}:${USER} $mountPoint; + fi + fi +} + +if [ "$1" ]; then + + if [ $UID -ne 0 ]; then + echo "Permission denied!"; + help; + exit 1; + fi + + #immudex-crypt RUID is EUID of sudo, which spawning immudex-crypt + if $(pidof -sq sudo); then + export RUID=$(grep '^Uid:' /proc/$(pidof -s sudo)/status | awk '{printf $2}'); + export USER=$(grep "$RUID" /etc/passwd | cut -d ":" -f1); + fi + + option=$(echo $1 | cut -d '=' -f 1); + value=$(echo $1 | cut -d '=' -f 2-); + + case $option in + "--list") list;; + "--open") if [ "$value" ]; then open $value; + else help; exit 1; + fi;; + "--close") if [ "$value" ]; then close $value; + else help; exit 1; + fi;; + "--create") if [ "$value" ]; then + create $value; + open $value; + set_ownership $value; + else help; exit 1; + fi;; + "--help") help; exit 0;; + "--version") version; exit 0;; + *) help;; + esac +else + help; exit 1; +fi diff --git a/immudex-meteo b/immudex-meteo new file mode 100755 index 0000000..9a0c6c0 --- /dev/null +++ b/immudex-meteo @@ -0,0 +1,47 @@ +#!/bin/bash + +function help() { + echo "immudex-meteo script fetching weather status from wttr.in webpage." + echo "The weather status is availabel to get in 3 formats described below"; + echo "in options."; + echo; + echo "Usage: immudex-meteo [--short | --long | --micro location] [--help] [--version]"; + echo; + echo "Options:"; + echo " --short location Short human readable format with one small ascii art."; + echo " --long location Long format, more readable, weather for every stage of the day and 2-day forecast"; + echo " --micro location Micro format, one line with details (current weather)"; + echo " --help Prints this message"; + echo " --version Prints information about version, author and copyrights"; + echo; + echo "Exmaples:"; + echo " immudex-meteo --short London Current weather in London in short format."; + echo " immudex-meteo --long Berlin Weather for whole day in Berlin and 2-day forecast."; + echo " immudex-meteo --micro Warszawa One line with weather information from Warsaw, good for motd's or resources monitors."; + echo; + echo "Report bugs to "; +} + +function version() { + echo "immudex-meteo 1.0"; + echo; + echo "Copyright (C) 2026 morketsmerke.org"; + echo "This is free software; see the source for copying conditions. There is NO"; + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; + echo; + echo "Written by xf0r3m."; +} + +if [ "$1" ]; then + case $1 in + "--short") curl wttr.in/${2}?format=2\&lang=pl;; + "--long") curl wttr.in/${2}?lang=pl;; + "--micro") curl wttr.in/${2}?format=4;; + "--help") help; exit 0;; + "--version") version; exit 0;; + *) help; exit 1;; + esac +else + help; + exit 1; +fi diff --git a/immudex-motd/immudex-motd b/immudex-motd/immudex-motd new file mode 100755 index 0000000..dcf1793 --- /dev/null +++ b/immudex-motd/immudex-motd @@ -0,0 +1,107 @@ +#!/bin/bash + + +if [ "$1" ]; then + if [ "$1" = "--help" ]; then + echo "immudex-motd prints configurable message of the day."; + echo "Information and its quantity can be changed via the configuration file."; + echo "Script using figlet basic font and lolcat for print header of message."; + echo; + echo "Usage: immudex-motd [--help] [--version]"; + echo; + echo "Options:"; + echo " --help Print this message."; + echo " --version Print information about version, author and copyright"; + echo; + echo "Files:"; + echo " /etc/motd.conf Script configuration file."; + echo " /usr/share/doc/immudex-motd/motd.conf.sample Example configuration file."; + echo; + echo "Examples:"; + echo " immudex-motd Run a script."; + echo; + echo "Report bugs to "; + exit 0; + fi + if [ "$1" = "--version" ]; then + echo "immudex-motd 1.0"; + echo; + echo "Copyright (C) 2026 morketsmerke.org"; + echo "This is free software; see the source for copying conditions. There is NO"; + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; + echo; + echo "Written by xf0r3m."; + exit 0; + fi +fi + +if [ -f /etc/motd.conf ]; then + source /etc/motd.conf; +else + source /usr/share/doc/immudex-motd/motd.conf.sample; +fi + +echo -en "\e[1m"; echo "$(hostname)" | /usr/bin/figlet | lolcat; echo -en "\e[0m"; +echo; +echo "Today is: $(date)"; +echo; +echo "System summary: "; +cpuIdle=$(vmstat | tail -1 | awk '{printf $15}'); +cpuUsage=$((100 - $cpuIdle)); +echo -e " \tCPU: ${cpuUsage}%"; +echo -e " \tMEM: $(free -h | sed -n '2p' | awk '{printf $7}' | sed 's/i//') Free"; +if [ "$MOUNT_POINTS" ]; then + echo -e " \tMount points:\tFree/Total\t(Usage%)"; + for mountPoint in $MOUNT_POINTS; do + if $(df -h 2>/dev/null | grep -q "${mountPoint}"); then + diskSize=$(df -h 2> /dev/null | grep "${mountPoint}" | awk '{printf $2}'); + diskFree=$(df -h 2> /dev/null | grep "${mountPoint}" | awk '{printf $4}'); + diskUsage_perc=$(df -h 2> /dev/null | grep "${mountPoint}" | sed 's/%//' | awk '{printf $5}'); + echo -e "\t$(echo $mountPoint | sed 's,\$,,'):\t\t${diskFree}/${diskSize}\t(${diskUsage_perc}%)"; + fi + done +fi +if $(echo $OPTIONS | grep -q 'cryptparts'); then + if $(df -h 2> /dev/null | grep -q '/dev/mapper'); then + i=1; + echo -e " \tCRYPT_PARTi: Free/Total (Usage%)"; + amountOfDisks=$(df -h 2> /dev/null | grep '/dev/mapper' | wc -l | awk '{printf $1}'); + while [ $i -le $amountOfDisks ]; do + diskSize=$(df -h 2> /dev/null | grep '/dev/mapper' | sed -n "${i}p" | awk '{printf $2}'); + diskFree=$(df -h 2> /dev/null | grep '/dev/mapper' | sed -n "${i}p" | awk '{printf $4}'); + diskUsage_perc=$(df -h 2> /dev/null | grep '/dev/mapper' | sed -n "${i}p" | sed 's/%//' | awk '{printf $5}'); + #FCP = First Crypt Partition + echo -e " \tCRYPT_PART${i}: ${diskFree}/${diskSize} (${diskUsage_perc}%)"; + i=$((i + 1)); + done + else + echo -e " \tCRYPT_PART: N/A"; + fi +fi +echo -e " \tIP: $(ip addr show $(sed -n '2p' /proc/net/route | awk '{printf $1}') | grep 'inet\ ' | awk '{printf $2"\n"}')"; +echo -e " \tPROCESSES: $(ps -aux | wc -l | awk '{printf $1}')"; +if $(uptime | grep -q 'day'); then + utime=$(uptime | awk '{printf $3" "$4" "$5}' | sed -e 's/\,$//' -e 's,:,h ,'); + echo -e "\tUPTIME: ${utime}m"; +else + utime=$(uptime | awk '{printf $3}' | sed -e 's/,//' -e 's,:,h ,'); + if $(echo $utime | grep -q "h"); then + echo -e " \tUPTIME: ${utime}m"; + else + echo -e " \tUPTIME: 0h ${utime}m"; + fi +fi +echo -e " \t$(uptime | grep -o "load.*$" | tr [a-z] [A-Z])"; +echo; +if [ -x /usr/bin/immudex-meteo ]; then +echo "Weather:"; + if [ "$LOCATION" ]; then + /usr/bin/immudex-meteo --micro $LOCATION; + fi +fi +echo; +if [ "$FOOTER" ]; then + echo -e "$FOOTER"; +fi +echo; +echo "===================================================================="; diff --git a/immudex-motd/motd.conf b/immudex-motd/motd.conf new file mode 100644 index 0000000..6c3ea21 --- /dev/null +++ b/immudex-motd/motd.conf @@ -0,0 +1,18 @@ + +#MOUNT_POINTS - turning on file system space level monitoring. Mount points +#puted to variable must separated with space and $ on end up."; +MOUNT_POINTS="/$ /home$"; + +#OPTIONS - storage triggers for additional jobs, which script can do. At this +#moment we have: +#cryptparts - file system space level monitoring for LUKS parted disks, +#weather - put one line current weather status for declared location. It's +#requires LOCATION option configured. +OPTIONS="cryptparts weather"; + +#FOOTER - custom information printed before script end his execution. It could +#be anything. +FOOTER="morketsmerke.org @ 2026 https://github.com/xf0r3m/immudex-tools" + +#LOCATION - not required option, it will be used to prints weather information +LOCATION="Warszawa"; diff --git a/immudex-pl b/immudex-pl new file mode 100755 index 0000000..fa9e196 --- /dev/null +++ b/immudex-pl @@ -0,0 +1,140 @@ +#!/bin/bash + +GREEN="\e[32m"; +RED="\e[31m"; +ENDCOLOR="\e[0m"; +SYSTEM_CC=$(echo $LANG | cut -c 1-2); + +function help() { + echo "immudex-pl opening (play) links. Script creates menu from link list, which"; + echo "can be open via mpv (with yt-dlp hook). Normally links are open as"; + echo "audio stream. Script work in loop, which means you can change playback"; + echo "while the current one is still playing. When you need to exit type any letter instead of number."; + echo "Script is not only for YouTube Links, it can also open"; + echo "internet radios or shoutcasts. The link list can be downloaded and does"; + echo "not need to be stored on the target device. Script will delete the"; + echo "file at the end of its execution. "; + echo; + echo "Usage: immudex-pl [--video --format=240p...1080p] [--help] [--version] link-list"; + echo; + echo "Options:"; + echo " --video --format=240p...1080p Open link as video."; + echo " --help Print this message."; + echo " --version Print information about version, author and copyrights."; + echo; + echo "Files:"; + echo " /usr/share/doc/immudex-pl/links.list.example Example link list file."; + echo; + echo "Examples:" + echo " immudex-pl ~/radio-links.txt Open given link list as audio stream."; + echo " immudex-pl --video --format=360p ./yt-links Open given link list as video in 360p format."; + echo; + echo "Report bugs to "; +} + +function version() { + echo "immudex-pl 1.0"; + echo; + echo "Copyright (C) 2026 morketsmerke.org"; + echo "This is free software; see the source for copying conditions. There is NO"; + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; + echo; + echo "Written by xf0r3m."; +} + +if [ "$1" ] && [ $1 = "--video" ]; then + video=1; + shift; + if $(echo $1 | grep -q '\-\-format'); then + format=$(echo $1 | grep -o '[0-9]' | awk '{printf $1}') + fi + shift; + file=$1; +elif [ "$1" ] && [ $1 = "--help" ]; then + help; + exit 0; +elif [ "$1" ] && [ $1 = "--version" ]; then + version; + exit 0; +else + file=$1; +fi + + +if echo $file | grep -q 'http'; then + echo -n "Getting link list..."; + wget -q $file -O /tmp/playlist.txt; + if [ $? -eq 0 ]; then + echo -e "[ ${GREEN}OK${ENDCOLOR} ]"; + file="/tmp/playlist.txt"; + else + echo -e "[ ${RED}FAIL${ENDCOLOR} ]"; + help; + exit 1; + fi +fi + +if [ "$file" ]; then + PS3="Link: "; + linkNames=$(cut -d ":" -f 1 $file | sed 's/\ /_/g' | awk '{printf $1" "}') + select name in $linkNames; do + if [ "$MPVPID" ]; then kill $MPVPID; fi + if [ ! "$name" ]; then break; fi + link=$(grep "$name" $file | cut -d ":" -f 2-3); + if [ ! "$link" ]; then + linkName=$(echo $name | sed 's/_/\ /g'); + link=$(grep "$linkName" $file | cut -d ":" -f 2-3); + fi + if echo $link | grep -q "youtube"; then + link=$(echo $link | sed 's/\ //g'); + if [ "$video" ]; then + #ytplay -v $link -f $format + #format="--ytdl-format=$(grep "$link" $file | cut -d ":" -f 4-)"; + echo "Getting requested video format ID..."; + video=$(yt-dlp --list-formats $link 2>/dev/null | grep "$format" | sed -n '1p' | awk '{printf $1}') + if [ ! "$video" ]; then + echo -e "Getting requested video format ID...[ ${RED}FAILED${ENDCOLOR} ]"; + exit 1; + else + echo -e "Getting requested video format ID...[ ${GREEN}OK${ENDCOLOR} ]"; + fi + + echo "Getting appropiate audio format ID for video..."; + audio=$(yt-dlp --list-formats $link 2>/dev/null | grep 'audio only' | grep "$SYSTEM_CC" | sed -n '1p' | awk '{printf $1}'); + if [ ! "$audio" ]; then + echo -e "Getting audio format based on your locales...[ ${RED}FAILED${ENDCOLOR} ]"; + echo "Getting high quality audio stream format..."; + audio=$(yt-dlp --list-formats $link 2>/dev/null | grep 'audio only' | grep "high" | sed -n '1p' | awk '{printf $1}'); + if [ ! "$audio" ]; then + echo "No audio stream found...[ ${RED}DEAD${ENDCOLOR} ]"; + exit 1; + else + echo -e "Getting high quality audio stream format...[ ${GREEN}OK${ENDCOLOR} ]"; + fi + else + echo -e "Getting audio format based on your locales...[ ${GREEN}OK${ENDCOLOR} ]"; + fi + fmat="--ytdl-format=${video}+${audio}"; + echo "MPV is starting up..."; + mpv $fmat $link > /dev/null 2>&1 & MPVPID=$! + + else + #ytplay -a $link -f best[height=360] + format="--no-video"; + echo "MPV is starting up..."; + mpv $format $link > /dev/null 2>&1 & MPVPID=$! + fi + else + mpv --no-video $link > /tmp/pl.log 2>&1 & MPVPID=$!; + tail -f /tmp/pl.log | grep "icy-title" & + fi + #echo "MPV: $MPVPID"; + done +else + help; + exit 1; +fi + +if [ -f /tmp/playlist.txt ]; then + rm /tmp/playlist.txt; +fi diff --git a/immudex-shoutcasts b/immudex-shoutcasts new file mode 100755 index 0000000..3c33211 --- /dev/null +++ b/immudex-shoutcasts @@ -0,0 +1,162 @@ +#!/bin/bash + +GREEN="\e[32m"; +RED="\e[31m"; +ENDCOLOR="\e[0m"; +BOLD="\e[1m"; +BOLD_GREEN="\e[1;32m"; +BOLD_YELLOW="\e[1;33m"; +BOLD_BLUE="\e[1;34m"; + +function help() { + echo "immudex-shoutcasts script that search internet radios or shoutcasts in two sources xiph.org icecast"; + echo "directory and download .m3u file from radio-browser.info based on a space-separated keywords."; + echo "Data from radio-browser.info are limited to 30 results."; + echo; + echo "Usage: immudex-shoutcasts [--source=icecast | radio] [--help] [--version] --keywords=keyword1...keywordN"; + echo; + echo "Options:"; + echo " --source=icecast/radio This parameter specifies source, if we want define a source. It can be omitted, then both sources will be searched."; + echo " --keywords=keyword1...keywordsN This parameter is required, it pass keywords to search. Keywords are space-separated."; + echo " --help Print this message."; + echo " --version Print information about version, author and copyrights."; + echo; + echo "Examples:"; + echo " immudex-shoutcasts --keywords=Classic Rock Script will be search internet radios and shoutcast for 'Classic Rock' keywords"; + echo " immudex-shoutcasts --source=radio --keywords=lofi Script will be search internet radios (because source is given) for 'lofi' keyword"; + echo; + echo "Files:" + echo " /tmp/icecast.idx Temporary file, store search results from icecast directory for parsing."; + echo " /tmp/radio.idx Temporary file, downloaded .m3u file from radio-browser.info store search results for parsing."; + echo; + echo "Report bugs to "; +} + +function version() { + echo "immudex-shoutcasts 1.0"; + echo; + echo "Copyright (C) 2026 morketsmerke.org"; + echo "This is free software; see the source for copying conditions. There is NO"; + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; + echo; + echo "Written by xf0r3m."; +} + + +function getDataBetweenHtmlMarks() { + grep "$1" $2 | sed -n "${3}p" | cut -d ">" -f 2 | cut -d "<" -f 1; +} + +function listOfStations() { + query=$1; + src=$2; + + case $src in + "icecast") wget http://dir.xiph.org/search?q=$query -O /tmp/icecast.idx >> /dev/null 2>&1; + file="/tmp/icecast.idx";; + "radio") wget "https://de1.api.radio-browser.info/m3u/stations/search?limit=30&name=${query}&hidebroken=true&order=clickcount&reverse=true" -O /tmp/radio.idx >> /dev/null 2>&1; + file="/tmp/radio.idx"; + dos2unix $file; + esac + + if [ ! -f $file ]; then + echo -e "${RED}There is no internet connection or sources are currently"; + echo -e "unavailable.${ENDCOLOR}"; + exit 1; + fi + + case $src in + "icecast") amountOfStations=$(grep 'card-title' $file | wc -l);; + "radio") amountOfStations=$(grep '#EXTINF' $file | wc -l);; + esac + + case $src in + "icecast") echo -e "${BOLD}Icecast directory:${ENDCOLOR}";; + "radio") echo -e "${BOLD}radio-browser.info:${ENDCOLOR}";; + esac + + i=1; + while [ $i -le $amountOfStations ]; do + case $src in + "icecast") stationName=$(getDataBetweenHtmlMarks 'card-title' $file $i);; + "radio") stationName=$(grep '#EXTINF' $file | sed -n "${i}p" | cut -d "," -f 2-);; + esac + if [ "$src" = "icecast" ]; then + whatIsPlayingNow=$(getDataBetweenHtmlMarks 'card-subtitle' $file $i); + fi + case $src in + "icecast") link=$(grep 'Play' $file | sed -n "${i}p" | cut -d '"' -f 2);; + "radio") link=$(grep '://' $file | sed -n "${i}p");; + esac + echo -e "${BOLD}${i}.${ENDCOLOR} ${BOLD_YELLOW}${stationName}${ENDCOLOR}"; + if [ "$whatIsPlayingNow" ]; then + echo -e "\t${BOLD}Now playing:${ENDCOLOR} ${BOLD_BLUE}${whatIsPlayingNow}${ENDCOLOR}"; + unset whatIsPlayingNow; + fi + echo -e "\t${BOLD}Link:${ENDCOLOR} ${BOLD_GREEN}${link}${ENDCOLOR}"; + i=$(expr $i + 1); + done + unset i; + echo; +} + +if [ "$1" ]; then + + if [ "$1" ] && [ "$1" = "--help" ]; then + help; + exit 0; + elif [ "$1" ] && [ "$1" = "--version" ]; then + version; + exit 0; + fi + + option=$(echo $1 | cut -d '=' -f 1); + if [ "$option" = "--source" ]; then + src=$(echo $1 | cut -d '=' -f 2); + search=$(echo $* | cut -d '=' -f 3-); + elif [ "$option" = "--keywords" ]; then + search=$(echo $* | cut -d "=" -f 2-); + fi +else + help; + exit 1; +fi + +if [ "$src" ]; then + listOfStations "$search" $src; + if [ "$src" = "icecast" ]; then + file="/tmp/icecast.idx"; + else + file="/tmp/radio.idx"; + fi +else + listOfStations "$search" 'icecast'; + listOfStations "$search" 'radio'; + + PS3="source? "; + select src in 'icecast' 'radio'; do + case $src in + 'icecast') file="/tmp/icecast.idx";; + 'radio') file="/tmp/radio.idx";; + *) exit 0; + esac + break + done +fi + +echo -n "Station? "; +read station; +if $(echo $station | grep -q '[0-9]') && [ $station -le 30 ]; then + case $file in + '/tmp/icecast.idx') link=$(grep 'Play' $file | sed -n "${station}p" | cut -d '"' -f 2);; + '/tmp/radio.idx') link=$(grep '://' $file | sed -n "${station}p");; + esac + case $src in + "icecast") stationName=$(getDataBetweenHtmlMarks 'card-title' $file $station);; + "radio") stationName=$(grep '#EXTINF' $file | sed -n "${station}p" | cut -d "," -f 2-);; + esac + echo -e "${BOLD}Station:${ENDCOLOR} ${BOLD_YELLOW}${stationName}${ENDCOLOR}"; + mpv --no-video $link; +else + exit 0; +fi diff --git a/immudex-ytplay b/immudex-ytplay new file mode 100755 index 0000000..4634065 --- /dev/null +++ b/immudex-ytplay @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 + +import sys +import subprocess +import re +from youtube_search import YoutubeSearch + +def usage(): + + print('''immudex-ytplay script for playing a video or audio track from YouTube. Script +can search based on given keywords and return list of results. User choose +one of result or repeats searching with 'r' || 'R' answer to number from +list result. Then script quering YouTube for available formats and table +with possible format are printed. User have to put video and audio quality +from table in requested format: videoQualityID+audioQualityID. There are +a hint. Script is half-interactive. + +Usage: immudex-ytplay [--search='keyword1...keywordN' --video | --audio] [--video youtube_link] [--audio youtube_link] [--help] [--version] + +Options: + --search='keyword1...keywordN' --video/--audio Search given keywords on YouTube and play video or audiotrack. + --video YouTube_Link Play YouTube video. + --audio YouTube_Link Play only YouTube video audiotrack. + --help Print this message. + --version Print information about version, author and copyrights. + +Examples: + immudex-ytplay --search='lofi' --audio Script will be search a lofi keyword in YouTube and play only audio tracks from choosen video. + immudex-ytplay --video https://youtube.com/watch?v=... Script will be play a video from given link, of course is publicly available. + immudex-ytplay --audio https://youtube.com/watch?v=... Script will be play a audio track from given video link. The principle of video playback also applies here. + +Report bugs to ''') + +def version(): + print('''immudex-ytplay 1.0 + +Copyright (C) 2026 morketsmerke.org +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +Written by xf0r3m.''') + +def ytSearch(keywords, maxResults=15): + + i = "r" + while isinstance(i, str) and (i == "r" or i == "R"): + subprocess.run('clear') + results = YoutubeSearch(keywords, max_results=maxResults).to_dict() + + index = 1 + for video in results: + print(f"\033[1m\033[91m{index}\033[0m. Title: \033[92m{video['title']}\033[0m") + print(f" Channel: \033[93m{video['channel']}\033[0m, Duration: \033[94m{video['duration']}\033[0m, PubDate: \033[95m{video['publish_time']}\033[0m") + index += 1 + + i = input("Put number of video you wanna watch or put 'r' | 'R' to reload search result or send any other key to quit: ") + if isinstance(i, str) and i != 'r' and i != 'R' and not re.search("[0-9]+", i): + sys.exit(0) + + i = int(i) - 1 + return(results[i]['id'], results[i]['title'], results[i]['channel'], results[i]['duration'], results[i]['publish_time']) + +def getFormat(videoID): + subprocess.run(['yt-dlp', '--list-formats', 'https://youtube.com/watch?v=' + videoID]) + f = input("Please choose youtube video format, you need put video+audio ID of quality in this format or type anything else to quit:") + if not re.search("[0-9]{3}\+[0-9]{3}|[0-9]{2}", f): + sys.exit(0) + else: + return f + +if len(sys.argv) == 2: + if sys.argv[1] == '--help': + usage() + sys.exit(0) + elif sys.argv[1] == '--version': + version() + sys.exit(0) + +if len(sys.argv) < 2: + usage() + sys.exit(2) + +option=sys.argv[1].split("=", 1)[0] + +if option == '--search': + if len(sys.argv) > 2: + if sys.argv[2] == '--video': + mode = "video" + elif sys.argv[2] == '--audio': + mode = "audio" + else: + usage() + sys.exit(2) + keywords = sys.argv[1].split("=", 1)[1] + + video = ytSearch(keywords) + subprocess.run('clear') + + if mode == 'audio': + ytFormat = "--no-video" + else: + ytFormat = "--ytdl-format=" + getFormat(video[0]) + + subprocess.run('clear') + print(f"\033[91m1\033[0m. Title: \033[92m{video[1]}\033[0m") + print(f" Channel: \033[93m{video[2]}\033[0m, Duration: \033[94m{video[3]}\033[0m, PubDate: \033[95m{video[4]}\033[0m") + print("===================================================================") + + subprocess.run(['mpv', ytFormat, 'https://youtube.com/watch?v=' + video[0]]) + else: + usage() + sys.exit(2) + +elif sys.argv[1] == '--audio': + if len(sys.argv) > 2: + link=sys.argv[2] + ytFormat="--no-video" + subprocess.run(['mpv', ytFormat, link]) + else: + usage() + sys.exit(2) + +elif sys.argv[1] == '--video': + if len(sys.argv) > 2: + link=sys.argv[2] + videoID=link[-11:] + ytFormat="--ytdl-format=" + getFormat(videoID) + subprocess.run(['mpv', ytFormat, link]) + else: + usage() + sys.exit(2) -- 2.39.5