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

📃 fix: replace every ~ AND ,, for posix compliance #666

Closed
wants to merge 5 commits 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
12 changes: 6 additions & 6 deletions core/tabs/applications-setup/dwmtitus-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@

clone_config_folders() {
# Ensure the target directory exists
[ ! -d ~/.config ] && mkdir -p ~/.config
[ ! -d "$HOME/.config" ] && mkdir -p "$HOME/.config"

# Iterate over all directories in config/*
for dir in config/*/; do
# Extract the directory name
dir_name=$(basename "$dir")

# Clone the directory to ~/.config/
# Clone the directory to $HOME/.config/
if [ -d "$dir" ]; then
cp -r "$dir" ~/.config/
printf "%b\n" "${GREEN}Cloned $dir_name to ~/.config/${RC}"
cp -r "$dir" "$HOME/.config/"
printf "%b\n" "${GREEN}Cloned $dir_name to $HOME/.config/${RC}"
else
printf "%b\n" "${RED}Directory $dir_name does not exist, skipping${RC}"
fi
Expand All @@ -153,11 +153,11 @@
# Set the variable BG_DIR to the path where backgrounds will be stored
BG_DIR="$PIC_DIR/backgrounds"

# Check if the ~/Pictures directory exists
# Check if the $HOME/Pictures directory exists
if [ ! -d "$PIC_DIR" ]; then
# 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}"
mkdir ~/Pictures
mkdir "$HOME/Pictures"
printf "%b\n" "${GREEN}Directory was created in Home folder${RC}"
fi

Expand Down Expand Up @@ -192,7 +192,7 @@
"$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"

Check warning on line 195 in core/tabs/applications-setup/dwmtitus-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 The surrounding quotes actually unquote this. Remove or escape them. Raw Output: ./core/tabs/applications-setup/dwmtitus-setup.sh:195:64: warning: The surrounding quotes actually unquote this. Remove or escape them. (ShellCheck.SC2027)

Check warning on line 195 in core/tabs/applications-setup/dwmtitus-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./core/tabs/applications-setup/dwmtitus-setup.sh:195:64: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
exit 1
;;
esac
Expand Down Expand Up @@ -229,7 +229,7 @@
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DM"
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"

Check warning on line 232 in core/tabs/applications-setup/dwmtitus-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 The surrounding quotes actually unquote this. Remove or escape them. Raw Output: ./core/tabs/applications-setup/dwmtitus-setup.sh:232:68: warning: The surrounding quotes actually unquote this. Remove or escape them. (ShellCheck.SC2027)

Check warning on line 232 in core/tabs/applications-setup/dwmtitus-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./core/tabs/applications-setup/dwmtitus-setup.sh:232:68: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
exit 1
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/mybash-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ installStarshipAndFzf() {
if command_exists fzf; then
printf "%b\n" "${GREEN}Fzf already installed${RC}"
else
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
"$ESCALATION_TOOL" ~/.fzf/install
git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf"
"$ESCALATION_TOOL" "$HOME/.fzf/install"
fi
}

Expand Down
35 changes: 19 additions & 16 deletions core/tabs/system-setup/arch/server-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
;;
'[B') # Down arrow
((selected++))
if [ $selected -ge $num_options ]; then

Check warning on line 105 in core/tabs/system-setup/arch/server-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./core/tabs/system-setup/arch/server-setup.sh:105:44: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
selected=0
fi
;;
Expand Down Expand Up @@ -183,7 +183,7 @@
echo -ne "
Please select key board layout from this list"
# These are default key maps as presented in official arch repo archinstall
options=(us by ca cf cz de dk es et fa fi fr gr hu il it lt lv mk nl no pl ro ru se sg ua uk)

Check warning on line 186 in core/tabs/system-setup/arch/server-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Use semicolon or linefeed before 'fi' (or quote to make it literal). Raw Output: ./core/tabs/system-setup/arch/server-setup.sh:186:44: warning: Use semicolon or linefeed before 'fi' (or quote to make it literal). (ShellCheck.SC1010)

select_option "${options[@]}"
keymap=${options[$?]}
Expand Down Expand Up @@ -225,7 +225,7 @@

PS3='
Select the disk to install on: '
options=($(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2"|"$3}'))

Check warning on line 228 in core/tabs/system-setup/arch/server-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Prefer mapfile or read -a to split command output (or quote to avoid splitting). Raw Output: ./core/tabs/system-setup/arch/server-setup.sh:228:14: warning: Prefer mapfile or read -a to split command output (or quote to avoid splitting). (ShellCheck.SC2207)

select_option "${options[@]}"
disk=${options[$?]%|*}
Expand All @@ -242,7 +242,7 @@
while true
do
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}|[a-z0-9_-]{0,30}\$)$'
then
break
fi
Expand All @@ -266,21 +266,24 @@

# Loop through user input until the user gives a valid hostname, but allow the user to force save
while true
do
read -r -p "Please name your machine: " name_of_machine
# hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
then
break
fi
do
printf "%b" "Please name your machine: "
read -r machine_name

lower_machine_name=$(echo "$machine_name" | tr '[:upper:]' '[:lower:]')
adamperkowski marked this conversation as resolved.
Show resolved Hide resolved
if echo "$lower_machine_name" | grep -q '^[a-z][a-z0-9_.-]\{0,62\}[a-z0-9]$'
then
break
fi
# 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
if [[ "${force,,}" = "y" ]]
then
break
fi
done
export NAME_OF_MACHINE=$name_of_machine
printf "%b" "Hostname doesn't seem correct. Do you still want to save it? (y/N) "
read -r force
if [[ "$force" == "y" || "$force" == "Y" ]]
then
break
fi
done
export NAME_OF_MACHINE=$lower_machine_name
}

# Starting functions
Expand Down Expand Up @@ -376,7 +379,7 @@
mountallsubvol
}

if [[ "${DISK}" =~ "nvme" ]]; then
if echo "$DISK" | grep -q "nvme"; then
partition2=${DISK}p2
partition3=${DISK}p3
else
Expand Down Expand Up @@ -456,7 +459,7 @@
Checking for low memory systems <8G
-------------------------------------------------------------------------
"
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')

Check warning on line 462 in core/tabs/system-setup/arch/server-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. Raw Output: ./core/tabs/system-setup/arch/server-setup.sh:462:17: info: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. (ShellCheck.SC2002)
if [[ $TOTAL_MEM -lt 8000000 ]]; then
# Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything.
mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly.
Expand Down Expand Up @@ -495,12 +498,12 @@
nc=$(grep -c ^processor /proc/cpuinfo)
echo -ne "
-------------------------------------------------------------------------
You have " $nc" cores. And

Check warning on line 501 in core/tabs/system-setup/arch/server-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 nc is referenced but not assigned. Raw Output: ./core/tabs/system-setup/arch/server-setup.sh:501:32: warning: nc is referenced but not assigned. (ShellCheck.SC2154)
changing the makeflags for " $nc" cores. Aswell as
changing the compression settings.
-------------------------------------------------------------------------
"
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')

Check warning on line 506 in core/tabs/system-setup/arch/server-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. Raw Output: ./core/tabs/system-setup/arch/server-setup.sh:506:17: info: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. (ShellCheck.SC2002)
if [[ $TOTAL_MEM -gt 8000000 ]]; then
sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf
sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf
Expand Down
24 changes: 12 additions & 12 deletions core/tabs/utils/ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

. ../common-script.sh

# Check if ~/.ssh/config exists, if not, create it
if [ ! -f ~/.ssh/config ]; then
mkdir -p "$HOME/.ssh"
# Check if $HOME/.ssh/config exists, if not, create it
if [ ! -f "$HOME/.ssh/config" ]; then
mkdir -p "$HOME/.ssh"\
touch "$HOME/.ssh/config"
chmod 600 "$HOME/.ssh/config"
fi

# Function to show available hosts from ~/.ssh/config
# Function to show available hosts from $HOME/.ssh/config
show_available_hosts() {
printf "%b\n" "Available Systems:"
grep -E "^Host " "$HOME/.ssh/config" | awk '{print $2}'
Expand All @@ -28,18 +28,18 @@ ask_for_host_details() {
printf "%b\n" "Host $host_alias"
printf "%b\n" " HostName $host"
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" " UserKnownHostsFile=/dev/null"
} >> ~/.ssh/config
} >> "$HOME/.ssh/config"
printf "%b\n" "Host $host_alias added successfully."
}

# Function to generate SSH key if not exists
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..."
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
printf "%b\n" "SSH key already exists."
fi
Expand Down Expand Up @@ -151,7 +151,7 @@ move_directory_to_remote() {
remove_system() {
printf "%b\n" "Enter the alias of the host to remove: "
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."
}

Expand All @@ -160,9 +160,9 @@ view_ssh_config() {
printf "%b\n" "Enter the alias of the host to view (or press Enter to view all): "
read -r host_alias
if [ -z "$host_alias" ]; then
cat ~/.ssh/config
cat "$HOME/.ssh/config"
else
grep -A 3 "^Host $host_alias" ~/.ssh/config
grep -A 3 "^Host $host_alias" "$HOME/.ssh/config"
fi
}

Expand Down Expand Up @@ -250,4 +250,4 @@ done

checkEnv
checkEscalationTool
main
main
Loading