代码拉取完成,页面将自动刷新
#!/bin/bash
# ref: https://askubuntu.com/a/1397108/339791
# Error status variables
STATUS_OK=0
STATUS_ERROR=1
# Color settings
YELLOW_COLOR="\033[1;33m"
RED_COLOR="\033[0;31m"
OFF_COLOR="\033[0m"
# Set English language
LANG=en_US.UTF-8
# Execute it as root user
if [ "${USER}" != root ]; then
echo -e "${RED_COLOR}ERROR: must be root! Exiting...${OFF_COLOR}"
exit "${STATUS_ERROR}"
fi
# Current status
USED_BEFORE="$(df -k / | awk 'NR>1 {print $3}')"
# snapd revisions clean
if [ -n "$(command -v snap)" ]; then
# shellcheck disable=SC2162
read -p "→ Do you want to remove unused snapd revisions? [Y/n] " KEY
KEY="${KEY:0:1}" && KEY="${KEY,,}"
if [ "${KEY}" = "y" ] || [ "${KEY}" = "" ]; then
# remove unused snapd revisions
echo "Removing unused snapd revisions..."
snap set system refresh.retain=2
# shellcheck disable=SC2162
snap list --all | awk '/disabled/ {print $1, $3}' |
while read SNAP_NAME SNAP_REV; do
snap remove "${SNAP_NAME}" --revision="${SNAP_REV}";
done
if [ -d /var/lib/snapd/cache ] && [ -n "$(ls -A /var/lib/snapd/cache)" ]; then
rm /var/lib/snapd/cache/*
fi
echo "Nothing unused to uninstall"
else
echo "Task skipped"
fi
fi
# Current status
USED_AFTER="$(df -k / | awk 'NR>1 {print $3}')"
# Summary
echo -e "${YELLOW_COLOR}Freed up space: $(( (USED_BEFORE - USED_AFTER)/1024 )) MB${OFF_COLOR}"
exit "${STATUS_OK}"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。