Compare commits

...

5 Commits

Author SHA1 Message Date
Adam Perkowski
68cb0c7b15
Merge f688f0c9dd into 79eb752552 2024-10-08 23:40:02 +01:00
Adam Perkowski
f688f0c9dd
even more + ,, 2024-09-30 00:17:46 +02:00
Adam Perkowski
9618128ff8
more tildas 2024-09-28 21:04:14 +02:00
Adam Perkowski
858d1194fb
Merge remote-tracking branch 'upstream/main' into tilda_env 2024-09-28 21:01:29 +02:00
Adam Perkowski
96af3c9b6e
Changed every ~ to $HOME 2024-09-24 13:38:07 +02:00
4 changed files with 33 additions and 30 deletions

View File

@ -129,17 +129,17 @@ picom_animations() {
clone_config_folders() { clone_config_folders() {
# Ensure the target directory exists # Ensure the target directory exists
[ ! -d ~/.config ] && mkdir -p ~/.config [ ! -d "$HOME/.config" ] && mkdir -p "$HOME/.config"
# Iterate over all directories in config/* # Iterate over all directories in config/*
for dir in config/*/; do for dir in config/*/; do
# Extract the directory name # Extract the directory name
dir_name=$(basename "$dir") dir_name=$(basename "$dir")
# Clone the directory to ~/.config/ # Clone the directory to $HOME/.config/
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
cp -r "$dir" ~/.config/ cp -r "$dir" "$HOME/.config/"
printf "%b\n" "${GREEN}Cloned $dir_name to ~/.config/${RC}" printf "%b\n" "${GREEN}Cloned $dir_name to $HOME/.config/${RC}"
else else
printf "%b\n" "${RED}Directory $dir_name does not exist, skipping${RC}" printf "%b\n" "${RED}Directory $dir_name does not exist, skipping${RC}"
fi fi
@ -153,11 +153,11 @@ configure_backgrounds() {
# Set the variable BG_DIR to the path where backgrounds will be stored # Set the variable BG_DIR to the path where backgrounds will be stored
BG_DIR="$PIC_DIR/backgrounds" BG_DIR="$PIC_DIR/backgrounds"
# Check if the ~/Pictures directory exists # Check if the $HOME/Pictures directory exists
if [ ! -d "$PIC_DIR" ]; then if [ ! -d "$PIC_DIR" ]; then
# If it doesn't exist, print an error message and return with a status of 1 (indicating failure) # If it doesn't exist, print an error message and return with a status of 1 (indicating failure)
printf "%b\n" "${RED}Pictures directory does not exist${RC}" printf "%b\n" "${RED}Pictures directory does not exist${RC}"
mkdir ~/Pictures mkdir "$HOME/Pictures"
printf "%b\n" "${GREEN}Directory was created in Home folder${RC}" printf "%b\n" "${GREEN}Directory was created in Home folder${RC}"
fi fi

View File

@ -61,8 +61,8 @@ installStarshipAndFzf() {
if command_exists fzf; then if command_exists fzf; then
printf "%b\n" "${GREEN}Fzf already installed${RC}" printf "%b\n" "${GREEN}Fzf already installed${RC}"
else else
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf"
"$ESCALATION_TOOL" ~/.fzf/install "$ESCALATION_TOOL" "$HOME/.fzf/install"
fi fi
} }

View File

@ -242,7 +242,7 @@ userinfo () {
while true while true
do do
read -r -p "Please enter username: " username read -r -p "Please enter username: " username
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]] if echo "$username" | grep -qE '^[a-z_][a-z0-9_-]{0,31}(\$)?$'
then then
break break
fi fi
@ -267,20 +267,23 @@ userinfo () {
# Loop through user input until the user gives a valid hostname, but allow the user to force save # Loop through user input until the user gives a valid hostname, but allow the user to force save
while true while true
do do
read -r -p "Please name your machine: " name_of_machine printf "%b" "Please name your machine: "
# hostname regex (!!couldn't find spec for computer name!!) read -r machine_name
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
lower_machine_name=$(echo "$machine_name" | tr '[:upper:]' '[:lower:]')
if echo "$lower_machine_name" | grep -q '^[a-z][a-z0-9_.-]\{0,62\}[a-z0-9]$'
then then
break break
fi fi
# if validation fails allow the user to force saving of the hostname # if validation fails allow the user to force saving of the hostname
read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force printf "%b" "Hostname doesn't seem correct. Do you still want to save it? (y/N) "
if [[ "${force,,}" = "y" ]] read -r force
if [[ "$force" == "y" || "$force" == "Y" ]]
then then
break break
fi fi
done done
export NAME_OF_MACHINE=$name_of_machine export NAME_OF_MACHINE=$lower_machine_name
} }
# Starting functions # Starting functions
@ -376,7 +379,7 @@ subvolumesetup () {
mountallsubvol mountallsubvol
} }
if [[ "${DISK}" =~ "nvme" ]]; then if echo "$DISK" | grep -q "nvme"; then
partition2=${DISK}p2 partition2=${DISK}p2
partition3=${DISK}p3 partition3=${DISK}p3
else else

View File

@ -2,16 +2,16 @@
. ../common-script.sh . ../common-script.sh
# Check if ~/.ssh/config exists, if not, create it # Check if $HOME/.ssh/config exists, if not, create it
if [ ! -f ~/.ssh/config ]; then if [ ! -f "$HOME/.ssh/config" ]; then
touch ~/.ssh/config touch "$HOME/.ssh/config"
chmod 600 ~/.ssh/config chmod 600 "$HOME/.ssh/config"
fi fi
# Function to show available hosts from ~/.ssh/config # Function to show available hosts from $HOME/.ssh/config
show_available_hosts() { show_available_hosts() {
printf "%b\n" "Available Systems:" printf "%b\n" "Available Systems:"
grep -E "^Host " ~/.ssh/config | awk '{print $2}' grep -E "^Host " "$HOME/.ssh/config" | awk '{print $2}'
printf "%b\n" "-------------------" printf "%b\n" "-------------------"
} }
@ -27,18 +27,18 @@ ask_for_host_details() {
printf "%b\n" "Host $host_alias" printf "%b\n" "Host $host_alias"
printf "%b\n" " HostName $host" printf "%b\n" " HostName $host"
printf "%b\n" " User $user" printf "%b\n" " User $user"
printf "%b\n" " IdentityFile ~/.ssh/id_rsa" printf "%b\n" " IdentityFile $HOME/.ssh/id_rsa"
printf "%b\n" " StrictHostKeyChecking no" printf "%b\n" " StrictHostKeyChecking no"
printf "%b\n" " UserKnownHostsFile=/dev/null" printf "%b\n" " UserKnownHostsFile=/dev/null"
} >> ~/.ssh/config } >> "$HOME/.ssh/config"
printf "%b\n" "Host $host_alias added successfully." printf "%b\n" "Host $host_alias added successfully."
} }
# Function to generate SSH key if not exists # Function to generate SSH key if not exists
generate_ssh_key() { generate_ssh_key() {
if [ ! -f ~/.ssh/id_rsa ]; then if [ ! -f "$HOME/.ssh/id_rsa" ]; then
printf "%b\n" "SSH key not found, generating one..." printf "%b\n" "SSH key not found, generating one..."
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" -C "$(whoami)@$(hostname)" ssh-keygen -t rsa -b 4096 -f "$HOME/.ssh/id_rsa -N" "" -C "$(whoami)@$(hostname)"
else else
printf "%b\n" "SSH key already exists." printf "%b\n" "SSH key already exists."
fi fi
@ -150,7 +150,7 @@ move_directory_to_remote() {
remove_system() { remove_system() {
printf "%b\n" "Enter the alias of the host to remove: " printf "%b\n" "Enter the alias of the host to remove: "
read -r host_alias read -r host_alias
sed -i "/^Host $host_alias/,+3d" ~/.ssh/config sed -i "/^Host $host_alias/,+3d" "$HOME/.ssh/config"
printf "%b\n" "Removed $host_alias from SSH configuration." printf "%b\n" "Removed $host_alias from SSH configuration."
} }
@ -159,9 +159,9 @@ view_ssh_config() {
printf "%b\n" "Enter the alias of the host to view (or press Enter to view all): " printf "%b\n" "Enter the alias of the host to view (or press Enter to view all): "
read -r host_alias read -r host_alias
if [ -z "$host_alias" ]; then if [ -z "$host_alias" ]; then
cat ~/.ssh/config cat "$HOME/.ssh/config"
else else
grep -A 3 "^Host $host_alias" ~/.ssh/config grep -A 3 "^Host $host_alias" "$HOME/.ssh/config"
fi fi
} }
@ -249,4 +249,4 @@ done
checkEnv checkEnv
checkEscalationTool checkEscalationTool
main main