Merge branch 'master' of git.axenov.dev:anthony/shell

This commit is contained in:
2025-03-18 13:45:33 +08:00
16 changed files with 422 additions and 80 deletions

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Original filename: docker-volume-snapshot
# Author: Juned Khatri
# License: MIT
# Repo: https://github.com/junedkhatri31/docker-volume-snapshot
set -e -o pipefail
programname=`basename "$0"`
display_usage() {
echo "usage: $programname (create|restore) source destination"
echo " create create snapshot file from docker volume"
echo " restore restore snapshot file to docker volume"
echo " source source path"
echo " destination destination path"
echo
echo "Tip: Supports tar's compression algorithms automatically"
echo " based on the file extention, for example .tar.gz"
echo
echo "Examples:"
echo "docker-volume-snapshot create xyz_volume xyz_volume.tar"
echo "docker-volume-snapshot create xyz_volume xyz_volume.tar.gz"
echo "docker-volume-snapshot restore xyz_volume.tar xyz_volume"
echo "docker-volume-snapshot restore xyz_volume.tar.gz xyz_volume"
}
case "$1" in
"create")
if [[ -z "$2" || -z "$3" ]]; then display_usage; exit 1; fi
directory=`dirname "$3"`
if [ "$directory" == "." ]; then directory=$(pwd); fi
filename=`basename "$3"`
docker run --rm -v "$2:/source" -v "$directory:/dest" busybox tar cvaf "/dest/$filename" -C /source .
;;
"restore")
if [[ -z "$2" || -z "$3" ]]; then display_usage; exit 1; fi
directory=`dirname "$2"`
if [ "$directory" == "." ]; then directory=$(pwd); fi
filename=`basename "$2"`
docker run --rm -v "$3:/dest" -v "$directory:/source" busybox tar xvf "/source/$filename" -C /dest
;;
*)
display_usage
exit 1 # Command to come out of the program with status 1
;;
esac

View File

@@ -3,46 +3,60 @@
# https://gist.github.com/anthonyaxenov/02c00c965be4eb5bb163a153abdf4c2b
# https://itsfoss.com/free-up-space-ubuntu-linux/
df -h
echo ""
echo
echo
df -hx tmpfs
echo
echo
echo "[1/5] Removing apt caches and unused packages"
echo ""
echo
sudo apt autoremove --purge
sudo apt autoclean
sudo apt clean
echo ""
echo "[2/5] Removing old journalctl logs"
echo ""
echo
echo "[2/5] Removing old system logs"
echo
sudo journalctl --vacuum-time=1d
sudo rm -rf /var/log/journal/user-*@*
sudo rm -rf /var/log/journal/system*@*
sudo rm /var/log/{syslog,dmesg,btmp}.*
sudo rm /var/log/{auth,dpkg,kern,alternatives,dmesg}.log.*
echo ""
echo
echo "[3/5] Cleaning user trash and thumbnails"
echo ""
echo
rm -rf ~/.local/share/Trash/files/*
rm -rf ~/.cache/thumbnails/*
echo ""
echo
echo "[4/5] Cleaning out dangling docker objects"
echo ""
echo
docker system prune -f
# docker system prune -af
echo ""
echo
echo "[5/5] Removing disabled unused snaps"
echo ""
echo
sudo snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
sudo snap remove "$snapname" --revision="$revision"
done
sudo snap list --all \
| awk '/disabled/{print $1, $3}' \
| while read snapname revision; do
sudo snap remove "$snapname" --revision="$revision"
done
echo ""
echo ""
df -h
echo
echo
df -hx tmpfs
echo
echo

View File

@@ -29,4 +29,5 @@ apt install -y \
mariadb-server \
mariadb-client \
nginx \
certbot
certbot \
python3-certbot-nginx

View File

@@ -41,13 +41,6 @@ sudo apt install -y \
notify-osd \
fonts-open-sans \
libnotify-bin \
gnome-software \
gnome-software-plugin-flatpak \
gnome-software-plugin-snap \
terminator \
geoclue-2.0 \
redshift \
redshift-gtk \
samba \
dkms

51
tools/ubuntu-server.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
sudo apt install -y ca-certificates curl && \
sudo install -m 0755 -d /etc/apt/keyrings && \
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \
sudo chmod a+r /etc/apt/keyrings/docker.asc && \
source /etc/os-release && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
sudo apt update && \
sudo apt upgrade -y --autoremove && \
sudo apt install -y \
apt-transport-https \
build-essential \
ca-certificates \
git \
cmake \
curl \
dialog \
gettext \
gnupg \
htop \
libcurl4-gnutls-dev \
libexpat1-dev \
libghc-zlib-dev \
libssl-dev \
lsb-release \
make \
mc \
meld \
nano \
neofetch \
net-tools \
nmap \
p7zip-full \
unzip \
ffmpeg \
inotify-tools \
notify-osd \
fonts-open-sans \
libnotify-bin \
tree \
nginx \
certbot \
python3-certbot-nginx \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin