feat: new structure for utilities script
This commit is contained in:
parent
c582114570
commit
059b64e8ba
20 changed files with 18 additions and 98 deletions
|
@ -1,53 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
declare -A dns_servers=(
|
||||
["Google"]="8.8.8.8,8.8.4.4"
|
||||
["Cloudflare"]="1.1.1.1"
|
||||
["403"]="10.202.10.202,10.202.10.102"
|
||||
["Shecan"]="178.22.122.100,185.51.200.2"
|
||||
)
|
||||
|
||||
display_dns_list() {
|
||||
echo "Available DNS Servers:"
|
||||
i=1
|
||||
for dns_name in "${!dns_servers[@]}"; do
|
||||
echo "$i. ${dns_name}"
|
||||
((i++))
|
||||
done
|
||||
}
|
||||
|
||||
select_dns() {
|
||||
read -p "Select a DNS server (enter the name or number): " selected_input
|
||||
|
||||
if [[ $selected_input =~ ^[0-9]+$ ]]; then
|
||||
if ((selected_input >= 1 && selected_input <= ${#dns_servers[@]})); then
|
||||
selected_name=$(echo "${!dns_servers[@]}" | cut -d ' ' -f $selected_input)
|
||||
selected_dns=${dns_servers[$selected_name]}
|
||||
echo "Selected DNS server: $selected_dns"
|
||||
else
|
||||
echo "Invalid number. Please select a valid number."
|
||||
select_dns
|
||||
fi
|
||||
else
|
||||
if [[ -n ${dns_servers[$selected_input]} ]]; then
|
||||
selected_dns=${dns_servers[$selected_input]}
|
||||
echo "Selected DNS server: $selected_dns"
|
||||
else
|
||||
echo "Invalid name. Please select a valid name."
|
||||
select_dns
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
update_resolv_conf() {
|
||||
sudo sh -c "echo '' > /etc/resolv.conf"
|
||||
IFS=',' read -ra dns_array <<<"$1"
|
||||
for dns in "${dns_array[@]}"; do
|
||||
echo "nameserver $dns" | sudo tee -a /etc/resolv.conf >/dev/null
|
||||
done
|
||||
echo "Updated /etc/resolv.conf with DNS servers: $1"
|
||||
}
|
||||
|
||||
display_dns_list
|
||||
select_dns
|
||||
update_resolv_conf "$selected_dns"
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
check_sudo() {
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
echo "Please run the script with sudo."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ask_prompt() {
|
||||
local question="$1"
|
||||
while true; do
|
||||
read -p "$question (Y/N): " choice
|
||||
case "$choice" in
|
||||
[Yy]) return 0 ;;
|
||||
[Nn]) return 1 ;;
|
||||
*) echo "Please enter Y or N." ;;
|
||||
esac
|
||||
done
|
||||
}
|
|
@ -7,7 +7,7 @@ export NEKORAY_PATH=/opt/nekoray/nekoray
|
|||
export CODE_PATH=/opt/vscode/code
|
||||
export DOTFILES=$HOME/.dots-hyprland
|
||||
export VOID_PACKAGES_PATH=$HOME/.local/pkgs/void-packages
|
||||
export DNS_CHANGER=$HOME/.scripts/dns-changer.sh
|
||||
export DNS_CHANGER=$HOME/.scripts/dns-changer/main.sh
|
||||
export STEAM_OS=$HOME/.steam-os/main.sh
|
||||
|
||||
if [ -d "/home/$USER/platform-tools" ]; then
|
||||
|
|
41
stow.sh
41
stow.sh
|
@ -6,8 +6,9 @@ source ./scripts/utils/helpers.sh
|
|||
CONFIGS_DIR="$(pwd)/configs"
|
||||
DOTFILES_DIR="$CONFIGS_DIR/dotfiles"
|
||||
SHELL_DIR="$CONFIGS_DIR/shell/zsh"
|
||||
SHORTCUTS_DIR="$CONFIGS_DIR/shortcuts"
|
||||
UTILS_DIR="$CONFIGS_DIR/utils"
|
||||
HYPRLAND_DIR="$CONFIGS_DIR/hyprland"
|
||||
SHORTCUTS_DIR="$CONFIGS_DIR/shortcuts"
|
||||
|
||||
display_help() {
|
||||
echo "Usage: [-s | -u] [-h]"
|
||||
|
@ -21,37 +22,29 @@ create_target_dir() {
|
|||
mkdir -p ~/.config
|
||||
}
|
||||
|
||||
stow_shortcuts() {
|
||||
create_symlinks $SHORTCUTS_DIR ~/.local/share/applications
|
||||
|
||||
log "Shortcuts stowed successfully!"
|
||||
}
|
||||
|
||||
stow_dotfiles() {
|
||||
create_symlinks $DOTFILES_DIR ~/.config
|
||||
create_symlinks $SHELL_DIR ~
|
||||
|
||||
log "Dotfiles stowed successfully!"
|
||||
}
|
||||
|
||||
stow_hyprland() {
|
||||
create_symlinks $HYPRLAND_DIR ~/.config
|
||||
|
||||
log "Hyprland stowed successfully!"
|
||||
}
|
||||
|
||||
stow() {
|
||||
create_target_dir
|
||||
stow_dotfiles
|
||||
stow_shortcuts
|
||||
stow_hyprland
|
||||
|
||||
create_symlinks $SHELL_DIR ~
|
||||
create_symlinks $DOTFILES_DIR ~/.config
|
||||
log "Dotfiles stowed successfully!"
|
||||
|
||||
create_symlinks $HYPRLAND_DIR ~/.config
|
||||
log "Hyprland stowed successfully!"
|
||||
|
||||
create_symlinks $SHORTCUTS_DIR ~/.local/share/applications
|
||||
log "Shortcuts stowed successfully!"
|
||||
|
||||
create_symlinks $UTILS_DIR ~
|
||||
log "Utilities stowed successfully!"
|
||||
}
|
||||
|
||||
unstow() {
|
||||
delete_symlinks $SHELL_DIR ~
|
||||
delete_symlinks $DOTFILES_DIR ~/.config
|
||||
delete_symlinks $SHORTCUTS_DIR ~/.local/share/applications
|
||||
delete_symlinks $HYPRLAND_DIR ~/.config
|
||||
delete_symlinks $SHORTCUTS_DIR ~/.local/share/applications
|
||||
delete_symlinks $UTILS_DIR ~
|
||||
|
||||
log "All configs ustowed successfully !"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue