mirror of
https://github.com/Snigdha-OS/snigdhaos-system-installation.git
synced 2025-09-21 22:04:55 +02:00
⚡️ perf(error): add error handling and increase readability
This commit is contained in:
@@ -1,70 +1,53 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo
|
|
||||||
echo "Changing Permissions..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
chmod 750 /etc/sudoers.d
|
# Define a function to print a message with a blank line before and after
|
||||||
chmod 750 /etc/polkit-1/rules.d
|
print_message() {
|
||||||
chgrp polkitd /etc/polkit-1/rules.d
|
echo
|
||||||
|
echo "$1"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
echo
|
# Define a function to handle errors
|
||||||
echo "Changed Permissions..."
|
handle_error() {
|
||||||
echo
|
echo "Error: $1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
echo
|
# Change permissions
|
||||||
echo "Copying /skel to /root..."
|
print_message "Changing Permissions..."
|
||||||
echo
|
chmod 750 /etc/sudoers.d || handle_error "Failed to change permissions for /etc/sudoers.d"
|
||||||
|
chmod 750 /etc/polkit-1/rules.d || handle_error "Failed to change permissions for /etc/polkit-1/rules.d"
|
||||||
|
chgrp polkitd /etc/polkit-1/rules.d || handle_error "Failed to change group for /etc/polkit-1/rules.d"
|
||||||
|
print_message "Changed Permissions..."
|
||||||
|
|
||||||
cp -aT /etc/skel/ /root/
|
# Copy /skel to /root
|
||||||
|
print_message "Copying /skel to /root..."
|
||||||
|
cp -aT /etc/skel/ /root/ || handle_error "Failed to copy /skel to /root"
|
||||||
|
print_message "Copied /skel to /root..."
|
||||||
|
|
||||||
echo
|
# Remove Autologin
|
||||||
echo "Copied /skel to /root..."
|
print_message "Removing Autologin..."
|
||||||
echo
|
rm -rfv /etc/systemd/system/getty@tty1.service.d || handle_error "Failed to remove autologin"
|
||||||
|
print_message "Removed Autologin..."
|
||||||
|
|
||||||
echo
|
# Fix Bluetooth
|
||||||
echo "Removing Autologin..."
|
print_message "Fixing Bluetooth..."
|
||||||
echo
|
sed -i "s/#AutoEnable=false/AutoEnable=true/g" /etc/bluetooth/main.conf || handle_error "Failed to fix bluetooth"
|
||||||
|
echo 'load-module module-switch-on-connect' | tee --append /etc/pulse/default.pa || handle_error "Failed to fix bluetooth"
|
||||||
|
print_message "Fixed Bluetooth..."
|
||||||
|
|
||||||
rm -rfv /etc/systemd/system/getty@tty1.service.d
|
# Work on Snigdha OS Config
|
||||||
|
print_message "Working on Snigdha OS Config..."
|
||||||
|
rm -fv /etc/sudoers.d/g_wheel || handle_error "Failed to remove g_wheel"
|
||||||
|
rm -fv /etc/polkit-1/rules.d/49-nopasswd_global.rules || handle_error "Failed to remove 49-nopasswd_global.rules"
|
||||||
|
rm -v /root/{.automated_script.sh,.zlogin} || handle_error "Failed to remove automated script and zlogin"
|
||||||
|
mv -v /etc/snigdhaos-release /etc/lsb-release || handle_error "Failed to move snigdhaos-release to lsb-release"
|
||||||
|
print_message "Completed working on Snigdha OS Config..."
|
||||||
|
|
||||||
echo
|
# Change root permission
|
||||||
echo "Removed Autologin..."
|
print_message "Change root permission..."
|
||||||
echo
|
chmod -v 700 /root || handle_error "Failed to change root permission"
|
||||||
|
print_message "Changed root permission..."
|
||||||
|
|
||||||
echo
|
# Task Completed
|
||||||
echo "Fixing Bluetooth..."
|
print_message "Task Completed!"
|
||||||
echo
|
|
||||||
|
|
||||||
sed -i "s/#AutoEnable=false/AutoEnable=true/g" /etc/bluetooth/main.conf
|
|
||||||
echo 'load-module module-switch-on-connect' | tee --append /etc/pulse/default.pa
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Fixed Bluetooth..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Working on Snigdha OS Config..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
rm -fv /etc/sudoers.d/g_wheel
|
|
||||||
rm -fv /etc/polkit-1/rules.d/49-nopasswd_global.rules
|
|
||||||
rm -v /root/{.automated_script.sh,.zlogin}
|
|
||||||
mv -v /etc/snigdhaos-release /etc/lsb-release
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Completed working on Snigdha OS Config..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Change root permission..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
chmod -v 700 /root
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Changed root permission..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Task Completed!"
|
|
||||||
echo
|
|
Reference in New Issue
Block a user