Compare commits

...

7 Commits

Author SHA1 Message Date
Adam Perkowski
1777606d9a
Merge 1d9471a3ce into e3688e9b3d 2024-10-25 14:09:48 +02:00
Adam Perkowski
e3688e9b3d
fix+refact(system-cleanup) (#856)
* fix(system-cleanup): some issues

* new packager quotes
2024-10-24 14:59:23 -05:00
Adam Perkowski
51631a16cb
feat: desktop entry & manpage installation through linutil-installer.sh (#802) 2024-10-24 14:55:56 -05:00
Adam Perkowski
1d9471a3ce
i hate sed 2024-10-05 13:46:53 +02:00
Adam Perkowski
4d478a1047
better sed expressions
i hate sed
2024-10-05 13:45:20 +02:00
Adam Perkowski
1dea0c2391
nix configuration (??)
i know that's not perfect. the best i can come up with right now.
2024-10-05 13:29:31 +02:00
Adam Perkowski
c9e1cc6b99
❄️ no flakes yet 2024-10-05 12:48:53 +02:00
8 changed files with 62 additions and 12 deletions

View File

@ -9,6 +9,9 @@ installAlacritty() {
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm alacritty
;;
nix-env)
"$PACKAGER" -iA nixpkgs.alacritty
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y alacritty
;;

View File

@ -15,6 +15,9 @@ install_adb() {
dnf|zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y android-tools
;;
nix-env)
"$PACKAGER" -iA nixpkgs.android-tools
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
exit 1

View File

@ -4,7 +4,6 @@
# Function to prompt the user for installation choice
choose_installation() {
clear
printf "%b\n" "${YELLOW}Choose what to install:${RC}"
printf "%b\n" "1. ${YELLOW}Docker${RC}"
printf "%b\n" "2. ${YELLOW}Docker Compose${RC}"
@ -36,6 +35,11 @@ install_docker() {
"$ESCALATION_TOOL" systemctl enable docker
"$ESCALATION_TOOL" systemctl start docker
;;
nix-env)
"$PACKAGER" -iA nixpkgs.docker
"$ESCALATION_TOOL" sed -i'' -E '/^[[:space:]]*virtualisation\.docker\.enable/!b; s/^([[:space:]]*)virtualisation\.docker\.enable.*/\1virtualisation.docker.enable = true;/' "$NIXOS_CONFIG" || echo 'virtualisation.docker.enable = true;' | "$ESCALATION_TOOL" tee -a "$NIXOS_CONFIG"
"$ESCALATION_TOOL" nixos-rebuild switch
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
@ -55,6 +59,9 @@ install_docker_compose() {
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm docker-compose
;;
nix-env)
"$PACKAGER" -iA nixpkgs.docker-compose
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1

View File

@ -15,6 +15,8 @@ setupDWM() {
"$ESCALATION_TOOL" "$PACKAGER" groupinstall -y "Development Tools"
"$ESCALATION_TOOL" "$PACKAGER" install -y libX11-devel libXinerama-devel libXft-devel imlib2-devel libxcb-devel unzip flameshot lxappearance feh mate-polkit # no need to include git here as it should be already installed via "Development Tools"
;;
nix-env)
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1

View File

@ -35,10 +35,10 @@ installLinutil() {
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm curl rustup man-db
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
"$ESCALATION_TOOL" "$PACKAGER" install -y curl rustup man-pages man-db man
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
@ -54,12 +54,23 @@ installLinutil() {
rustup default stable
cargo install --force linutil_tui
printf "%b\n" "${GREEN}Installed successfully.${RC}"
installExtra
;;
*) printf "%b\n" "${RED}Linutil not installed.${RC}" ;;
esac
esac
}
installExtra() {
printf "%b\n" "${YELLOW}Installing the manpage...${RC}"
"$ESCALATION_TOOL" mkdir -p /usr/share/man/man1
curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/man/linutil.1' | "$ESCALATION_TOOL" tee '/usr/share/man/man1/linutil.1' > /dev/null
printf "%b\n" "${YELLOW}Creating a Desktop Entry...${RC}"
"$ESCALATION_TOOL" mkdir -p /usr/share/applications
curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/linutil.desktop' | "$ESCALATION_TOOL" tee /usr/share/applications/linutil.desktop > /dev/null
printf "%b\n" "${GREEN}Done.${RC}"
}
checkEnv
checkEscalationTool
checkAURHelper

View File

@ -25,6 +25,11 @@ setup_flatpak() {
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak
;;
nix-env)
"$PACKAGER" -iA nixpkgs.flatpak
"$ESCALATION_TOOL" sed -i'' -E '/^[[:space:]]*services\.flatpak\.enable/!b; s/^([[:space:]]*)services\.flatpak\.enable.*/\1services.flatpak.enable = true;/' "$NIXOS_CONFIG" || echo 'services.flatpak.enable = true;' | "$ESCALATION_TOOL" tee -a "$NIXOS_CONFIG"
"$ESCALATION_TOOL" nixos-rebuild switch
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y flatpak
;;

View File

@ -78,6 +78,16 @@ checkPackageManager() {
if command_exists "${pgm}"; then
PACKAGER=${pgm}
printf "%b\n" "${CYAN}Using ${pgm} as package manager${RC}"
if [ $PACKAGER = 'nix-env' ] && [ -z "$NIXOS_CONFIG" ]; then
NIXOS_CONFIG="/etc/nixos/configuration.nix"
while [ ! -f "$NIXOS_CONFIG" ]; do
printf "%b\n" "${RED}configuration.nix not found.${RC}"
printf "%b" "${YELLOW}Enter the path manually: ${RC}"
read -r NIXOS_CONFIG
done
fi
break
fi
done
@ -127,7 +137,7 @@ checkDistro() {
checkEnv() {
checkEscalationTool
checkCommandRequirements "curl groups $ESCALATION_TOOL"
checkPackageManager 'nala apt-get dnf pacman zypper'
checkPackageManager 'nala apt-get dnf pacman zypper nix-env'
checkCurrentDirectoryWritable
checkSuperUser
checkDistro

13
core/tabs/system-setup/system-cleanup.sh Normal file → Executable file
View File

@ -26,16 +26,21 @@ cleanup_system() {
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
return 1
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}"
;;
esac
}
common_cleanup() {
if [ -d /var/tmp ]; then
"$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete
fi
if [ -d /tmp ]; then
"$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete
fi
if [ -d /var/log ]; then
"$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
fi
"$ESCALATION_TOOL" journalctl --vacuum-time=3d
}
@ -45,8 +50,12 @@ clean_data() {
case $clean_response in
y|Y)
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
if [ -d "$HOME/.cache" ]; then
find "$HOME/.cache/" -type f -atime +5 -delete
fi
if [ -d "$HOME/.local/share/Trash" ]; then
find "$HOME/.local/share/Trash" -mindepth 1 -delete
fi
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
;;
*)