Add scripts

This commit is contained in:
q3aql 2025-08-07 08:54:27 +02:00
parent 5e7314e661
commit 0090aaa07f
10 changed files with 330 additions and 0 deletions

40
scripts/cleaner-apt.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
function printf(){
echo "$1" "$2"
}
ls /root/ > /dev/null
if [ "$?" -eq 0 ] ; then
printf "Root -> OK"
else
if [ $USER != root ]; then
clear
printf ""
printf "Error: must be root"
printf "Exiting..."
printf ""
exit 0
fi
fi
printf "Cleaning apt cache..."
apt clean
printf "Removing old config files..."
apt purge $OLDCONF
#printf "Removing old kernels..."
#aptitude purge $OLDKERNELS
printf "Emptying every trashes..."
rm -rfv /home/*/.local/share/Trash/*/**
rm -rfv /root/.local/share/Trash/*/**
printf "Script Finished!"

20
scripts/update-electronmail.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
echo "Checking electronmail version"
touch /etc/electronmail_version.conf
version_electronmail=$(curl "https://github.com/vladimiry/ElectronMail/releases" 2> /dev/null | grep "releases/tag" | head -1 | cut -d "=" -f 4 | cut -d "/" -f 6 | cut -d '"' -f 1 | cut -d "v" -f 2)
version_electronmail_current=$(cat /etc/electronmail_version.conf)
if [ "${version_electronmail}" != "${version_electronmail_current}" ] ; then
echo "New electronmail version detected"
echo "Downloading electronmail"
rm -rf /tmp/electronmail.deb
wget -q --show-progress -c "https://github.com/vladimiry/ElectronMail/releases/download/v${version_electronmail}/electron-mail-${version_electronmail}-linux-amd64.deb" -O /tmp/electronmail.deb
echo "Installing electronmail"
apt install /tmp/electronmail.deb
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_electronmail}" > /etc/electronmail_version.conf
fi
else
echo "No updates for electronmail"
fi

42
scripts/update-ffmpeg.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
install_ffmpeg_gen(){
echo "Downloading ffmpeg"
rm -rf /tmp/ffmpeg.tar.xz
wget -q --show-progress -c "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz" -O /tmp/ffmpeg.tar.xz
echo "Installing ffmpeg"
tar Jxf /tmp/ffmpeg.tar.xz -C /tmp/
if [ -f /tmp/ffmpeg-master-latest-linux64-gpl/bin/ffmpeg ] ; then
cp -rf /tmp/ffmpeg-master-latest-linux64-gpl/bin/ffmpeg /usr/bin/
chmod +x /usr/bin/ffmpeg
fi
if [ -f /tmp/ffmpeg-master-latest-linux64-gpl/bin/ffprobe ] ; then
cp -rf /tmp/ffmpeg-master-latest-linux64-gpl/bin/ffprobe /usr/bin/
chmod +x /usr/bin/ffprobe
fi
if [ -f /tmp/ffmpeg-master-latest-linux64-gpl/bin/ffplay ] ; then
cp -rf /tmp/ffmpeg-master-latest-linux64-gpl/bin/ffplay /usr/bin/
chmod +x /usr/bin/ffplay
fi
if [ -d /tmp/ffmpeg-master-latest-linux64-gpl/man ] ; then
cp -rf /tmp/ffmpeg-master-latest-linux64-gpl/man/* /usr/share/man/
fi
rm -rf /tmp/ffmpeg.tar.xz
rm -rf /tmp/ffmpeg-master-latest-linux64-gpl
echo "Installation ffmpeg done"
}
echo "Checking ffmpeg version"
touch /etc/ffmpeg_version.conf
version_ffmpeg=$(curl "https://github.com/BtbN/FFmpeg-Builds/releases/tag/latest" 2> /dev/null | grep "<title>" | cut -d ">" -f 2 | cut -d "<" -f 1)
version_ffmpeg_current=$(cat /etc/ffmpeg_version.conf)
if [ "${version_ffmpeg}" != "${version_ffmpeg_current}" ] ; then
echo "New ffmpeg version detected"
install_ffmpeg_gen
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_ffmpeg}" > /etc/ffmpeg_version.conf
fi
else
echo "No updates for ffmpeg"
fi

58
scripts/update-firefox.sh Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
install_firefox_gen() {
download_url_firefox="${1}"
echo "Downloading firefox"
rm -rf /tmp/firefox.tar.xz
#wget -q --show-progress -c "${download_url_firefox}" -O /tmp/firefox.tar.xz
wget -q --show-progress -c "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US" -O /tmp/firefox.tar.xz
echo "Installing firefox"
if [ -d /usr/lib ] ; then
tar Jxf /tmp/firefox.tar.xz -C /usr/lib/
unlink /usr/bin/firefox 2> /dev/null
install_firefox_desktop
ln -s /usr/lib/firefox/firefox /usr/bin/firefox
chmod +x /usr/bin/firefox
fi
rm -rf /tmp/firefox.tar.xz
echo "Installation firefox done"
}
install_firefox_desktop() {
if [ -d /usr/share/applications ] ; then
echo '[Desktop Entry]' > /usr/share/applications/firefox.desktop
echo 'Name=Firefox' >> /usr/share/applications/firefox.desktop
echo 'Comment=Browse the World Wide Web' >> /usr/share/applications/firefox.desktop
echo 'GenericName=Web Browser' >> /usr/share/applications/firefox.desktop
echo 'X-GNOME-FullName=Firefox Web Browser' >> /usr/share/applications/firefox.desktop
echo 'Exec=/usr/lib/firefox/firefox-bin %u' >> /usr/share/applications/firefox.desktop
echo 'Terminal=false' >> /usr/share/applications/firefox.desktop
echo 'X-MultipleArgs=false' >> /usr/share/applications/firefox.desktop
echo 'Type=Application' >> /usr/share/applications/firefox.desktop
if [ -f /usr/lib/firefox/browser/chrome/icons/default/default48.png ] ; then
echo 'Icon=/usr/lib/firefox/browser/chrome/icons/default/default48.png' >> /usr/share/applications/firefox.desktop
else
echo 'Icon=firefox' >> /usr/share/applications/firefox.desktop
fi
echo 'Categories=Network;WebBrowser;' >> /usr/share/applications/firefox.desktop
echo 'MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;' >> /usr/share/applications/firefox.desktop
echo 'StartupWMClass=Firefox' >> /usr/share/applications/firefox.desktop
echo 'StartupNotify=true' >> /usr/share/applications/firefox.desktop
fi
}
echo "Checking firefox version"
touch /etc/firefox_version.conf
url_download=$(curl -I -s "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US" | grep Location | cut -d " " -f 2)
version_firefox=$(basename ${url_download})
version_firefox_current=$(cat /etc/firefox_version.conf)
if [ "${version_firefox}" != "${version_firefox_current}" ] ; then
echo "New firefox version detected"
install_firefox_gen "${url_download}"
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_firefox}" > /etc/firefox_version.conf
fi
else
echo "No updates for firefox"
fi

21
scripts/update-open-tv.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
echo "Checking open-tv version"
touch /etc/opentv_version.conf
version_opentv=$(curl "https://github.com/Fredolx/open-tv/releases" 2> /dev/null | grep "releases/tag" | head -1 | cut -d "=" -f 4 | cut -d "/" -f 6 | cut -d '"' -f 1 | cut -d "v" -f 2)
version_opentv_current=$(cat /etc/opentv_version.conf)
if [ "${version_opentv}" != "${version_opentv_current}" ] ; then
echo "New open-tv version detected"
echo "Downloading open-tv"
rm -rf /tmp/open-tv.deb
wget -q --show-progress -c "https://github.com/Fredolx/open-tv/releases/download/v${version_opentv}/Open.TV_${version_opentv}_amd64.deb" -O /tmp/open-tv.deb
echo "Installing open-tv"
apt install /tmp/open-tv.deb
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_opentv}" > /etc/opentv_version.conf
sed -i 's/Icon\=open_tv/Icon\=me-tv/g' "/usr/share/applications/Open TV.desktop"
fi
else
echo "No updates for open-tv"
fi

20
scripts/update-rclone.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
echo "Checking rclone version"
touch /etc/rclone_version.conf
version_rclone=$(curl "https://rclone.org/downloads/" 2> /dev/null | grep "\"release\"" | cut -d ">" -f 2 | cut -d "<" -f 1)
version_rclone_current=$(cat /etc/rclone_version.conf)
if [ "${version_rclone}" != "${version_rclone_current}" ] ; then
echo "New rclone version detected"
echo "Downloading rclone"
rm -rf /tmp/rclone.deb
wget -q --show-progress -c "https://downloads.rclone.org/rclone-current-linux-amd64.deb" -O /tmp/rclone.deb
echo "Installing rclone"
apt install /tmp/rclone.deb
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_rclone}" > /etc/rclone_version.conf
fi
else
echo "No updates for rclone"
fi

39
scripts/update-system.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
function update_packages() {
sudo flatpak update
sudo apt update
sudo apt upgrade -y
}
function update_kernel_stable() {
sudo apt install linux-image-amd64 -y
sudo apt autoremove
}
function update_scripts() {
sudo update-yazi.sh
sudo update-vim.sh
sudo update-rclone.sh
sudo update-ffmpeg.sh
sudo update-yt-dlp.sh
sudo update-open-tv.sh
sudo update-electronmail.sh
sudo update-firefox.sh
#sudo update-tabby.sh
#sudo update-plex.sh
}
function fstrim_run() {
echo "First Trimming"
sudo /sbin/fstrim -a -v
echo "Second Trimming"
sudo /sbin/fstrim -a -v
echo "Third Trimming"
sudo /sbin/fstrim -a -v
}
update_scripts
update_packages
update_kernel_stable
fstrim_run

31
scripts/update-vim.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
install_vim_gen(){
version_download="${1}"
echo "Downloading vim"
rm -rf /tmp/vim.appimage
vim_urlfile=$(curl -L "https://github.com/vim/vim-appimage/releases/tag/${version_download}" 2> /dev/null | grep "/Vim-${version_download}" | grep "href\=" | cut -d "=" -f 2 | cut -d '"' -f 2)
wget -q --show-progress -c "${vim_urlfile}" -O /tmp/vim.appimage
echo "Installing vim"
if [ -f /tmp/vim.appimage ] ; then
cp -rf /tmp/vim.appimage /usr/bin/vim
chmod +x /usr/bin/vim
fi
rm -rf /tmp/vim.appimage
echo "Installation vim done"
}
echo "Checking vim version"
touch /etc/vim_version.conf
version_vim=$(curl "https://github.com/vim/vim-appimage/releases" 2> /dev/null | grep "releases/tag" | head -1 | cut -d "=" -f 4 | cut -d "/" -f 6 | cut -d '"' -f 1)
version_vim_current=$(cat /etc/vim_version.conf)
if [ "${version_vim}" != "${version_vim_current}" ] ; then
echo "New vim version detected"
install_vim_gen "${version_vim}"
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_vim}" > /etc/vim_version.conf
fi
else
echo "No updates for vim"
fi

37
scripts/update-yazi.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
install_yazi_gen(){
version_download="${1}"
echo "Downloading yazi"
rm -rf /tmp/yazi.zip
wget -q --show-progress -c "https://github.com/sxyazi/yazi/releases/download/${version_download}/yazi-x86_64-unknown-linux-musl.zip" -O /tmp/yazi.zip
echo "Installing yazi"
cd /tmp
unzip -q yazi.zip
if [ -f yazi-x86_64-unknown-linux-musl/ya ] ; then
cp -rf yazi-x86_64-unknown-linux-musl/ya /usr/bin/
chmod +x /usr/bin/ya
fi
if [ -f yazi-x86_64-unknown-linux-musl/yazi ] ; then
cp -rf yazi-x86_64-unknown-linux-musl/yazi /usr/bin/
chmod +x /usr/bin/yazi
fi
rm -rf /tmp/yazi.zip
rm -rf /tmp/yazi-x86_64-unknown-linux-musl
echo "Installation yazi done"
}
echo "Checking yazi version"
touch /etc/yazi_version.conf
version_yazi=$(curl "https://github.com/sxyazi/yazi/releases" 2> /dev/null | grep "releases/tag" | grep -v "nightly" | head -1 | cut -d "=" -f 4 | cut -d "/" -f 6 | cut -d '"' -f 1)
version_yazi_current=$(cat /etc/yazi_version.conf)
if [ "${version_yazi}" != "${version_yazi_current}" ] ; then
echo "New yazi version detected"
install_yazi_gen "${version_yazi}"
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_yazi}" > /etc/yazi_version.conf
fi
else
echo "No updates for yazi"
fi

22
scripts/update-yt-dlp.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
echo "Checking yt-dlp version"
touch /etc/ytdlp_version.conf
version_ytdlp=$(curl "https://github.com/yt-dlp/yt-dlp/releases" 2> /dev/null | grep "releases/tag" | head -1 | cut -d "=" -f 4 | cut -d "/" -f 6 | cut -d '"' -f 1 | cut -d "v" -f 2)
version_ytdlp_current=$(cat /etc/ytdlp_version.conf)
if [ "${version_ytdlp}" != "${version_ytdlp_current}" ] ; then
echo "New yt-dlp version detected"
echo "Downloading yt-dlp"
rm -rf /tmp/yt-dlp
wget -q --show-progress -c "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux" -O /tmp/yt-dlp
echo "Installing yt-dlp"
cp -rf /tmp/yt-dlp /usr/bin/
error_install=$?
if [ ${error_install} -eq 0 ] ; then
echo "${version_ytdlp}" > /etc/ytdlp_version.conf
chmod +x /usr/bin/yt-dlp
echo "Installation yt-dlp done"
fi
else
echo "No updates for yt-dlp"
fi