Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote vars in utils #508

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions tabs/utils/auto-login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ configure_lightdm() {
printf "Enter username for LightDM autologin: "
read -r user

$ESCALATION_TOOL "printf '[Seat:*]' > /etc/lightdm/lightdm.conf.d/50-autologin.conf"
$ESCALATION_TOOL "printf 'autologin-user=$user' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"
$ESCALATION_TOOL "printf 'autologin-user-timeout=0' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"
"$ESCALATION_TOOL" "printf '[Seat:*]' > /etc/lightdm/lightdm.conf.d/50-autologin.conf"
"$ESCALATION_TOOL" "printf 'autologin-user=$user' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"
"$ESCALATION_TOOL" "printf 'autologin-user-timeout=0' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"

printf "LightDM has been configured for autologin.\n"
}

# Function to remove LightDM autologin
remove_lightdm_autologin() {
printf "Removing LightDM autologin configuration...\n"
$ESCALATION_TOOL rm -f /etc/lightdm/lightdm.conf.d/50-autologin.conf
"$ESCALATION_TOOL" rm -f /etc/lightdm/lightdm.conf.d/50-autologin.conf
printf "LightDM autologin configuration has been removed.\n"
}

Expand All @@ -65,18 +65,18 @@ configure_gdm() {
printf "Enter username for GDM autologin: "
read -r user

$ESCALATION_TOOL "printf '[daemon]' > /etc/gdm/custom.conf"
$ESCALATION_TOOL "printf 'AutomaticLoginEnable = true' >> /etc/gdm/custom.conf"
$ESCALATION_TOOL "printf 'AutomaticLogin = $user' >> /etc/gdm/custom.conf"
"$ESCALATION_TOOL" "printf '[daemon]' > /etc/gdm/custom.conf"
"$ESCALATION_TOOL" "printf 'AutomaticLoginEnable = true' >> /etc/gdm/custom.conf"
"$ESCALATION_TOOL" "printf 'AutomaticLogin = $user' >> /etc/gdm/custom.conf"

printf "GDM has been configured for autologin.\n"
}

# Function to remove GDM autologin
remove_gdm_autologin() {
printf "Removing GDM autologin configuration...\n"
$ESCALATION_TOOL sed -i '/AutomaticLoginEnable/d' /etc/gdm/custom.conf
$ESCALATION_TOOL sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf
"$ESCALATION_TOOL" sed -i '/AutomaticLoginEnable/d' /etc/gdm/custom.conf
"$ESCALATION_TOOL" sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf
printf "GDM autologin configuration has been removed.\n"
}

Expand All @@ -88,17 +88,17 @@ configure_sddm() {
read -r user
list_sessions # Show session options

$ESCALATION_TOOL "printf '[Autologin]' > /etc/sddm.conf"
$ESCALATION_TOOL "printf 'User=$user' >> /etc/sddm.conf"
$ESCALATION_TOOL "printf 'Session=$session' >> /etc/sddm.conf"
"$ESCALATION_TOOL" "printf '[Autologin]' > /etc/sddm.conf"
"$ESCALATION_TOOL" "printf 'User=$user' >> /etc/sddm.conf"
"$ESCALATION_TOOL" "printf 'Session=$session' >> /etc/sddm.conf"

printf "SDDM has been configured for autologin.\n"
}

# Function to remove SDDM autologin
remove_sddm_autologin() {
printf "Removing SDDM autologin configuration...\n"
$ESCALATION_TOOL sed -i '/\[Autologin\]/,+2d' /etc/sddm.conf
"$ESCALATION_TOOL" sed -i '/\[Autologin\]/,+2d' /etc/sddm.conf
printf "SDDM autologin configuration has been removed.\n"
}

Expand All @@ -110,17 +110,17 @@ configure_lxdm() {
read -r user
list_sessions # Show session options

$ESCALATION_TOOL sed -i "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf
$ESCALATION_TOOL sed -i "s|^#.*session=.*$|session=/usr/bin/${session}|; s|^session=.*$|session=/usr/bin/${session}|" /etc/lxdm/lxdm.conf
"$ESCALATION_TOOL" sed -i "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf
"$ESCALATION_TOOL" sed -i "s|^#.*session=.*$|session=/usr/bin/${session}|; s|^session=.*$|session=/usr/bin/${session}|" /etc/lxdm/lxdm.conf

printf "LXDM has been configured for autologin.\n"
}

# Function to remove LXDM autologin
remove_lxdm_autologin() {
printf "Removing LXDM autologin configuration...\n"
$ESCALATION_TOOL sed -i "s/^autologin=.*$/#autologin=/" /etc/lxdm/lxdm.conf
$ESCALATION_TOOL sed -i "s/^session=.*$/#session=/" /etc/lxdm/lxdm.conf
"$ESCALATION_TOOL" sed -i "s/^autologin=.*$/#autologin=/" /etc/lxdm/lxdm.conf
"$ESCALATION_TOOL" sed -i "s/^session=.*$/#session=/" /etc/lxdm/lxdm.conf
printf "LXDM autologin configuration has been removed.\n"
}

Expand Down
10 changes: 5 additions & 5 deletions tabs/utils/create-bootable-usb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ usage() {
list_devices() {
printf "%b\n" "${YELLOW} Available devices and partitions: ${RC}"
printf "\n"
$ESCALATION_TOOL lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
"$ESCALATION_TOOL" lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
printf "\n"
}

Expand Down Expand Up @@ -164,13 +164,13 @@ write_iso(){

# Display progress and create the bootable USB drive
printf "%b\n" "${YELLOW}Creating bootable USB drive...${RC}"
if ! $ESCALATION_TOOL dd if="$ISO_PATH" of="$USB_DEVICE" bs=4M status=progress oflag=sync; then
if ! "$ESCALATION_TOOL" dd if="$ISO_PATH" of="$USB_DEVICE" bs=4M status=progress oflag=sync; then
printf "%b\n" "${RED}Failed to create bootable USB drive${RC}"
exit 1
fi

# Sync to ensure all data is written
if ! $ESCALATION_TOOL sync; then
if ! "$ESCALATION_TOOL" sync; then
printf "%b\n" "${RED}Failed to sync data${RC}"
exit 1
fi
Expand All @@ -179,10 +179,10 @@ write_iso(){

# Eject the USB device
printf "%b\n" "${YELLOW}Ejecting ${USB_DEVICE}...${RC}"
if ! $ESCALATION_TOOL umount "${USB_DEVICE}"* 2>/dev/null; then
if ! "$ESCALATION_TOOL" umount "${USB_DEVICE}"* 2>/dev/null; then
printf "%b\n" "${RED}Failed to unmount ${USB_DEVICE}${RC}"
fi
if ! $ESCALATION_TOOL eject "$USB_DEVICE"; then
if ! "$ESCALATION_TOOL" eject "$USB_DEVICE"; then
printf "%b\n" "${RED}Failed to eject ${USB_DEVICE}${RC}"
fi

Expand Down
8 changes: 4 additions & 4 deletions tabs/utils/encrypt_decrypt_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ printf "%b\n" "${YELLOW}Ensuring OpenSSL is installed...${RC}"
if ! command_exists openssl; then
case $PACKAGER in
pacman)
$ESCALATION_TOOL ${PACKAGER} -Syu --noconfirm openssl
"$ESCALATION_TOOL" ${PACKAGER} -Syu --noconfirm openssl
;;
apt-get)
$ESCALATION_TOOL ${PACKAGER} update && $ESCALATION_TOOL ${PACKAGER} install -y openssl
"$ESCALATION_TOOL" ${PACKAGER} update && "$ESCALATION_TOOL" ${PACKAGER} install -y openssl
;;
dnf)
$ESCALATION_TOOL ${PACKAGER} install -y openssl
"$ESCALATION_TOOL" ${PACKAGER} install -y openssl
;;
zypper)
$ESCALATION_TOOL ${PACKAGER} install openssl
"$ESCALATION_TOOL" ${PACKAGER} install openssl
;;
*)
printf "%b\n" "${RED}Your Linux distribution is not supported by this script.${RC}"
Expand Down
12 changes: 6 additions & 6 deletions tabs/utils/power-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ installAutoCpufreq() {
printf "%b\n" "${YELLOW}git not found. Installing git...${RC}"
case ${PACKAGER} in
pacman)
$ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm git
"$ESCALATION_TOOL" ${PACKAGER} -S --needed --noconfirm git
;;
*)
$ESCALATION_TOOL ${PACKAGER} install -y git
"$ESCALATION_TOOL" ${PACKAGER} install -y git
;;
esac
fi
Expand All @@ -35,7 +35,7 @@ installAutoCpufreq() {
*)
cd auto-cpufreq
printf "%b\n" "${YELLOW}Running auto-cpufreq installer...${RC}"
$ESCALATION_TOOL ./auto-cpufreq-installer
"$ESCALATION_TOOL" ./auto-cpufreq-installer
;;
esac
cd ..
Expand All @@ -49,10 +49,10 @@ configureAutoCpufreq() {
# Check if the system has a battery to determine if it's a laptop
if [ -d /sys/class/power_supply/BAT0 ]; then
printf "%b\n" "${GREEN}System detected as laptop. Updating auto-cpufreq for laptop...${RC}"
$ESCALATION_TOOL auto-cpufreq --force powersave
"$ESCALATION_TOOL" auto-cpufreq --force powersave
else
printf "%b\n" "${GREEN}System detected as desktop. Updating auto-cpufreq for desktop...${RC}"
$ESCALATION_TOOL auto-cpufreq --force performance
"$ESCALATION_TOOL" auto-cpufreq --force performance
fi
else
printf "%b\n" "${RED}auto-cpufreq is not installed, skipping configuration.${RC}"
Expand All @@ -64,7 +64,7 @@ removeAutoCpufreqTweak() {

if command_exists auto-cpufreq; then
printf "%b\n" "${YELLOW}Resetting auto-cpufreq configuration...${RC}"
$ESCALATION_TOOL auto-cpufreq --force reset
"$ESCALATION_TOOL" auto-cpufreq --force reset
else
printf "%b\n" "${RED}auto-cpufreq is not installed, skipping removal.${RC}"
fi
Expand Down
30 changes: 15 additions & 15 deletions tabs/utils/service-control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ add_service() {
printf "\n"
printf "[Install]\n"
printf "WantedBy=multi-user.target\n"
} | $ESCALATION_TOOL tee "$SERVICE_FILE" > /dev/null
} | "$ESCALATION_TOOL" tee "$SERVICE_FILE" > /dev/null

# Set permissions and reload systemd
$ESCALATION_TOOL chmod 644 "$SERVICE_FILE"
$ESCALATION_TOOL systemctl daemon-reload
"$ESCALATION_TOOL" chmod 644 "$SERVICE_FILE"
"$ESCALATION_TOOL" systemctl daemon-reload
printf "Service $SERVICE_NAME has been created and is ready to be started.\n"

# Optionally, enable and start the service
Expand All @@ -121,12 +121,12 @@ remove_service() {

if [ -f "$SERVICE_FILE" ]; then
printf "Stopping and disabling the service...\n"
$ESCALATION_TOOL systemctl stop "$SERVICE_NAME"
$ESCALATION_TOOL systemctl disable "$SERVICE_NAME"
"$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME"
"$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME"

printf "Removing the service file...\n"
$ESCALATION_TOOL rm -f "$SERVICE_FILE"
$ESCALATION_TOOL systemctl daemon-reload
"$ESCALATION_TOOL" rm -f "$SERVICE_FILE"
"$ESCALATION_TOOL" systemctl daemon-reload
printf "Service $SERVICE_NAME has been removed.\n"
else
printf "Service $SERVICE_NAME does not exist.\n"
Expand All @@ -139,7 +139,7 @@ start_service() {
printf "Enter the name of the service to start (e.g., my_service):\n"
read -r SERVICE_NAME

if $ESCALATION_TOOL systemctl start "$SERVICE_NAME"; then
if "$ESCALATION_TOOL" systemctl start "$SERVICE_NAME"; then
printf "Service $SERVICE_NAME has been started.\n"
else
printf "Failed to start service: $SERVICE_NAME.\n"
Expand All @@ -152,7 +152,7 @@ stop_service() {
printf "Enter the name of the service to stop (e.g., my_service):\n"
read -r SERVICE_NAME

if $ESCALATION_TOOL systemctl stop "$SERVICE_NAME"; then
if "$ESCALATION_TOOL" systemctl stop "$SERVICE_NAME"; then
printf "Service $SERVICE_NAME has been stopped.\n"
else
printf "Failed to stop service: $SERVICE_NAME.\n"
Expand All @@ -165,7 +165,7 @@ enable_service() {
printf "Enter the name of the service to enable (e.g., my_service):\n"
read -r SERVICE_NAME

if $ESCALATION_TOOL systemctl enable "$SERVICE_NAME"; then
if "$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME"; then
printf "Service $SERVICE_NAME has been enabled.\n"
else
printf "Failed to enable service: $SERVICE_NAME.\n"
Expand All @@ -178,7 +178,7 @@ disable_service() {
printf "Enter the name of the service to disable (e.g., my_service):\n"
read -r SERVICE_NAME

if $ESCALATION_TOOL systemctl disable "$SERVICE_NAME"; then
if "$ESCALATION_TOOL" systemctl disable "$SERVICE_NAME"; then
printf "Service $SERVICE_NAME has been enabled.\n"
else
printf "Failed to enable service: $SERVICE_NAME.\n"
Expand Down Expand Up @@ -228,17 +228,17 @@ create_service_from_external() {
"$ESCALATION_TOOL" cp "$SERVICE_FILE" "$SYSTEMD_SERVICE_FILE"

# Set permissions and reload systemd
$ESCALATION_TOOL chmod 644 "$SYSTEMD_SERVICE_FILE"
$ESCALATION_TOOL systemctl daemon-reload
"$ESCALATION_TOOL" chmod 644 "$SYSTEMD_SERVICE_FILE"
"$ESCALATION_TOOL" systemctl daemon-reload
printf "Service $SERVICE_NAME has been created and is ready to be started.\n"

# Optionally, enable and start the service
printf "Do you want to start and enable the service now? (y/n)\n"
read -r START_ENABLE

if [ "$START_ENABLE" = "y" ]; then
$ESCALATION_TOOL systemctl start "$SERVICE_NAME"
$ESCALATION_TOOL systemctl enable "$SERVICE_NAME"
"$ESCALATION_TOOL" systemctl start "$SERVICE_NAME"
"$ESCALATION_TOOL" systemctl enable "$SERVICE_NAME"
printf "Service $SERVICE_NAME has been started and enabled.\n"
else
printf "Service $SERVICE_NAME has been created but not started.\n"
Expand Down
22 changes: 11 additions & 11 deletions tabs/utils/timeshift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ install_timeshift() {
if ! command_exists timeshift; then
case ${PACKAGER} in
pacman)
$ESCALATION_TOOL "${PACKAGER}" -S --noconfirm timeshift
"$ESCALATION_TOOL" "${PACKAGER}" -S --noconfirm timeshift
;;
*)
$ESCALATION_TOOL "${PACKAGER}" install -y timeshift
"$ESCALATION_TOOL" "${PACKAGER}" install -y timeshift
;;
esac
else
Expand All @@ -37,13 +37,13 @@ display_menu() {
# Function to list snapshots
list_snapshots() {
printf "%b\n" "${CYAN}Listing snapshots...${RC}"
$ESCALATION_TOOL timeshift --list-snapshots
"$ESCALATION_TOOL" timeshift --list-snapshots
}

# Function to list devices
list_devices() {
printf "%b\n" "${CYAN}Listing available devices...${RC}"
$ESCALATION_TOOL timeshift --list-devices
"$ESCALATION_TOOL" timeshift --list-devices
}

# Function to create a new snapshot
Expand All @@ -55,13 +55,13 @@ create_snapshot() {

if [ -z "$COMMENT" ] && [ -z "$TAG" ]; then
printf "%b\n" "${CYAN}Creating snapshot with no comment or tag...${RC}"
$ESCALATION_TOOL timeshift --create
"$ESCALATION_TOOL" timeshift --create
elif [ -z "$TAG" ]; then
printf "%b\n" "${CYAN}Creating snapshot with no tag...${RC}"
$ESCALATION_TOOL timeshift --create --comments "$COMMENT"
"$ESCALATION_TOOL" timeshift --create --comments "$COMMENT"
else
printf "%b\n" "${CYAN}Creating snapshot with tag: $TAG...${RC}"
$ESCALATION_TOOL timeshift --create --comments "$COMMENT" --tags "$TAG"
"$ESCALATION_TOOL" timeshift --create --comments "$COMMENT" --tags "$TAG"
fi

if [ $? -eq 0 ]; then
Expand All @@ -83,11 +83,11 @@ restore_snapshot() {
read -r SKIP_GRUB

if [ "$SKIP_GRUB" = "yes" ]; then
$ESCALATION_TOOL timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --skip-grub --yes
"$ESCALATION_TOOL" timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --skip-grub --yes
else
printf "%b\n" "${CYAN}Enter GRUB device (e.g., /dev/sda): ${RC}"
read -r GRUB_DEVICE
$ESCALATION_TOOL timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes
"$ESCALATION_TOOL" timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes
fi

if [ $? -eq 0 ]; then
Expand All @@ -105,7 +105,7 @@ delete_snapshot() {
read -r SNAPSHOT

printf "%b\n" "${YELLOW}Deleting snapshot $SNAPSHOT...${RC}"
$ESCALATION_TOOL timeshift --delete --snapshot "$SNAPSHOT" --yes
"$ESCALATION_TOOL" timeshift --delete --snapshot "$SNAPSHOT" --yes

if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}"
Expand All @@ -122,7 +122,7 @@ delete_all_snapshots() {

if [ "$CONFIRMATION" = "yes" ]; then
printf "%b\n" "${CYAN}Deleting all snapshots...${RC}"
$ESCALATION_TOOL timeshift --delete-all --yes
"$ESCALATION_TOOL" timeshift --delete-all --yes
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}"
else
Expand Down
Loading