From 16df0d5fe65986a123d37bcf005599c3113f1727 Mon Sep 17 00:00:00 2001 From: xf0r3m Date: Sat, 15 Mar 2025 10:41:58 +0100 Subject: [PATCH] =?utf8?q?Dodanie=20immudex-updates=20do=20test=C3=B3w.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- base.sh | 5 ++-- immudex-motd2 | 2 +- immudex-updates | 63 +++++++++++++++++++++++++++++++++++++++++ immudex_updates.service | 11 +++++++ 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100755 immudex-updates create mode 100644 immudex_updates.service diff --git a/base.sh b/base.sh index a14366d..87eba56 100644 --- a/base.sh +++ b/base.sh @@ -132,6 +132,7 @@ cp -vv ~/immudex/tools/sbin/immudex-crypt /usr/local/sbin; cp -vv ~/immudex/tools/sbin/immudex-hostname /usr/local/sbin; cp -vv ~/immudex/tools/sbin/immudex-install /usr/local/sbin; cp -vv ~/immudex/tools/sbin/immudex-upgrade /usr/local/sbin; +cp -vv ~/e5270/immudex-updates /usr/local/sbin; chown root:root /usr/local/sbin/*; chmod 544 /usr/local/sbin/*; @@ -149,7 +150,7 @@ if [ -f /usr/share/applications/qmmp.desktop ]; then ln -s /usr/share/applications/qmmp.desktop /usr/share/applications/qmmp-1.desktop; fi #cp -vv ~/immudex/files/immudex_hostname.service /etc/systemd/system; - +cp -vv ~/e5270/immudex_updates.service /etc/systemd/system; tar -xf ~/immudex/files/mozilla.tgz -C /etc/skel; wget https://ftp.morketsmerke.org/librewolf/librewolf.tgz -O /tmp/librewolf.tgz; @@ -159,7 +160,7 @@ wget https://ftp.morketsmerke.org/librewolf/16844254192.desktop -O /etc/skel/.co #Wyłączenie dla mnie immudex_hostname, ze względu na VPN #systemctl enable immudex_hostname.service; - +systemctl enable immudex_updates.service; cat >> /etc/bash.bashrc << EOL if [ ! -f /tmp/.motd ]; then diff --git a/immudex-motd2 b/immudex-motd2 index b15b2b5..ac5936c 100755 --- a/immudex-motd2 +++ b/immudex-motd2 @@ -45,6 +45,6 @@ fi echo -e " \t$(uptime | grep -o "load.*$" | tr '[a-z]' '[A-Z]')"; echo; echo -e "morketsmerke.org @ 2025 https://github.com/xf0r3m/immudex"; -#source /usr/local/bin/immudex-updates; +cat /tmp/immudex-updates.txt; echo; echo "===================================================================="; diff --git a/immudex-updates b/immudex-updates new file mode 100755 index 0000000..8343618 --- /dev/null +++ b/immudex-updates @@ -0,0 +1,63 @@ +#!/bin/bash + +RED="\e[31m"; +GREEN="\e[32m"; +YELLOW="\e[33m"; +ENDCOLOR="\e[0m"; + +FILE="/tmp/immudex-updates.txt"; + +function getVerFromRSSFeed() { + URL=$1; + echo $(curl $URL 2> /dev/null | grep '' | sed -n '2p' | sed -e 's/<title>//g' -e 's,,,g' | awk '{printf $1}') +} +echo "Obtaining updates information:" > $FILE; +echo " |" >> $FILE ; +if [ -x /usr/bin/librewolf ]; then + URL="https://codeberg.org/librewolf/source/releases.rss"; + newLibrewolfVer=$(getVerFromRSSFeed $URL); + currentLibrewolfVer=$(apt list --installed 2>/dev/null | grep 'librewolf' | awk '{printf $2}'); + if ! [ "$currentLibrewolfVer" = "$newLibrewolfVer" ]; then + echo -e " \`- New Librewolf version (${GREEN}${newLibrewolfVer}${ENDCOLOR}) is available." >> $FILE; + echo " |" >> $FILE; + fi +fi + +if [ -x /usr/local/bin/ncspot ]; then + URL="https://github.com/hrkfdn/ncspot/releases.atom"; + newNcspotVer=$(getVerFromRSSFeed $URL); + currentNcspotVer=$(ncspot -V | awk '{printf $2}'); + if ! [ "$currentNcspotVer" = "$newNcspotVer" ]; then + echo -e " \`- New ncspot version (${GREEN}${newNcspotVer}${ENDCOLOR}) is available." >> $FILE; + echo " |" >> $FILE; + fi +fi + +if [ -x /usr/local/bin/nu ]; then + URL="https://github.com/nushell/nushell/releases.atom"; + newNushellVer=$(getVerFromRSSFeed $URL); + currentNushellVer=$(nu -v | awk '{printf $1}'); + if ! [ "$currentNushellVer" = "$NewNushellVer" ]; then + echo -e " \`- New nushell version (${GREEN}${newNushellVer}${ENDCOLOR}) is available." >> $FILE; + echo " |"; + fi +fi + +debianVersion=$(cut -d "." -f 1 /etc/debian_version); +URL="https://micronews.debian.org/feeds/feed.rss"; +newDebianVersion=$(curl $URL 2>/dev/null | grep -o "Updated Debian ${debianVersion}: ${debianVersion}.[0-9]*" | sed -n '1p' | awk '{printf $4}'); +if ! [ "$newDebianVersion" = "$(cat /etc/debian_version)" ]; then + echo -e " \`- New Debian version (${YELLOW}${newDebianVersion}${ENDCOLOR})." >> $FILE; + echo " |" >> $FILE; +fi + +apt update > /dev/null 2>&1; +packagesToUpdate=$(expr $(apt list --upgradable 2> /dev/null | wc -l) - 1); +if [ $packagesToUpdate -lt 0 ]; then packagesToUpdate=0; fi + +if [ $packagesToUpdate -lt 10 ]; then color=${GREEN}; +elif [ $packagesToUpdate -lt 50 ]; then color=${YELLOW}; +else color=${RED}; +fi + +echo -e " \`- ${color}${packagesToUpdate}${ENDCOLOR} packages ready to update." >> $FILE; diff --git a/immudex_updates.service b/immudex_updates.service new file mode 100644 index 0000000..84083a6 --- /dev/null +++ b/immudex_updates.service @@ -0,0 +1,11 @@ +[Unit] +Description=Refresh Debian packages list +After=network-online.target +Wants=network-online.target +Before=display-manager.service +[Service] +Type=OneShot +ExecStart=/usr/local/sbin/immudex-updates +RemainAfterExit=yes +[Install] +WantedBy=multi-user.target -- 2.39.5