wip
This commit is contained in:
parent
f532a924fb
commit
3f5b980ddc
@ -70,6 +70,11 @@ ensure_symlink() {
|
|||||||
source=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.symlinks.$1.source) &>/dev/null
|
source=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.symlinks.$1.source) &>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If this is still empty, last attempt, let's try use the hostname of the machine
|
||||||
|
if [ -z "$source" ]; then
|
||||||
|
source=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.symlinks.$1.sources.$(hostname)) &>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
# If this is still empty, we can't continue and should throw up an error
|
# If this is still empty, we can't continue and should throw up an error
|
||||||
if [ -z "$source" ]; then
|
if [ -z "$source" ]; then
|
||||||
printfe "%s\n" "red" " - No valid source defined for $1"
|
printfe "%s\n" "red" " - No valid source defined for $1"
|
||||||
@ -77,6 +82,22 @@ ensure_symlink() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
check_or_make_symlink $source $target
|
check_or_make_symlink $source $target
|
||||||
|
|
||||||
|
# Let's check if there was a chmod defined for the symlink
|
||||||
|
chmod=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.symlinks.$1.chmod 2>/dev/null)
|
||||||
|
|
||||||
|
if [ -n "$chmod" ]; then
|
||||||
|
# Let's see if the current target has the correct chmod
|
||||||
|
current_chmod=$(stat -c %a $target)
|
||||||
|
if [ "$current_chmod" != "$chmod" ]; then
|
||||||
|
printfe "%s" "yellow" " - Changing chmod of $target to $chmod"
|
||||||
|
# Replace ~ with $HOME in target
|
||||||
|
target=$(echo $target | sed "s|~|$HOME|g")
|
||||||
|
chmod $chmod $target
|
||||||
|
else
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
symlinks() {
|
symlinks() {
|
||||||
|
@ -157,41 +157,57 @@ add_to_hosts() {
|
|||||||
# $1: file to check
|
# $1: file to check
|
||||||
# $2: link location
|
# $2: link location
|
||||||
check_or_make_symlink() {
|
check_or_make_symlink() {
|
||||||
if [ ! -L $1 ]; then
|
SOURCE=$1
|
||||||
if [ -f $1 ]; then
|
TARGET=$2
|
||||||
mv $1 $1.bak
|
|
||||||
printfe "%s\n" "yellow" " - Backed up $1 to $1.bak"
|
|
||||||
fi
|
|
||||||
mkdir -p $(dirname $1)
|
|
||||||
ln -s $2 $1
|
|
||||||
printfe "%s\n" "green" " - Created symlink $2 -> $1"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Confirm the symlink that already exists point to the correct location
|
# Take any ~ and replace it with $HOME
|
||||||
if [ -L $1 ]; then
|
SOURCE=$(echo $SOURCE | sed "s|~|$HOME|g")
|
||||||
if [ "$(readlink $1)" != $2 ]; then
|
TARGET=$(echo $TARGET | sed "s|~|$HOME|g")
|
||||||
printfe "%s\n" "yellow" " - Symlink $1 exists but points to the wrong location"
|
|
||||||
printfe "%s\n" "yellow" " Expected: $2"
|
# If target is already a symlink, we should check if it points to the correct location
|
||||||
printfe "%s\n" "yellow" " Actual: $(readlink $1)"
|
if [ -L $TARGET ]; then
|
||||||
|
if [ "$(readlink $TARGET)" != "$SOURCE" ]; then
|
||||||
|
printfe "%s\n" "yellow" " - Symlink $TARGET exists but points to the wrong location"
|
||||||
|
printfe "%s\n" "yellow" " Expected: $SOURCE"
|
||||||
|
printfe "%s\n" "yellow" " Actual: $(readlink $TARGET)"
|
||||||
printfe "%s\n" "yellow" " Fixing symlink"
|
printfe "%s\n" "yellow" " Fixing symlink"
|
||||||
rm $1
|
rm $TARGET
|
||||||
mkdir -p $(dirname $1)
|
mkdir -p $(dirname $TARGET)
|
||||||
ln -s $2 $1
|
ln -s $SOURCE $TARGET
|
||||||
printfe "%s\n" "green" " Created symlink $2 -> $1"
|
printfe "%s\n" "green" " Created symlink $TARGET -> $SOURCE"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -L $1 ]; then
|
# If target is a file and it's not a symlink, we should back it up
|
||||||
printfe "%s\n" "red" " - Failed to create symlink $2 -> $1"
|
if [ -f $TARGET ] && [ ! -L $TARGET ]; then
|
||||||
return
|
printfe "%s\n" "yellow" " - File $TARGET exists, backing up and creating symlink"
|
||||||
|
mv $TARGET $TARGET.bak
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If the target is already a symlink, and it points to the correct location, we should return and be happy
|
||||||
|
if [ -L $TARGET ]; then
|
||||||
printfe "%s" "green" " - OK: "
|
printfe "%s" "green" " - OK: "
|
||||||
printfe "%-30s" "blue" "$1"
|
printfe "%-30s" "blue" "$SOURCE"
|
||||||
printfe "%s" "cyan" " -> "
|
printfe "%s" "cyan" " -> "
|
||||||
printfe "%-30s\n" "blue" "$2"
|
printfe "%-30s\n" "blue" "$TARGET"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the symlink
|
||||||
|
mkdir -p $(dirname $TARGET)
|
||||||
|
ln -s $SOURCE $TARGET
|
||||||
|
|
||||||
|
# Check if the symlink was created successfully
|
||||||
|
if [ ! -L $TARGET ]; then
|
||||||
|
printfe "%s\n" "red" " - Failed to create symlink $TARGET -> $SOURCE"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
printfe "%s" "green" " - Added new symlink: "
|
||||||
|
printfe "%-30s" "blue" "$SOURCE"
|
||||||
|
printfe "%s" "cyan" " -> "
|
||||||
|
printfe "%-30s\n" "blue" "$TARGET"
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_line() {
|
clear_line() {
|
||||||
|
@ -17,6 +17,14 @@ config:
|
|||||||
source: ~/dotfiles/config/ssh/config.d
|
source: ~/dotfiles/config/ssh/config.d
|
||||||
target: ~/.ssh/config.d
|
target: ~/.ssh/config.d
|
||||||
|
|
||||||
|
ssh_authorized_keys:
|
||||||
|
sources:
|
||||||
|
mennos-laptop: ~/dotfiles/config/ssh/authorized_keys/mennos-laptop
|
||||||
|
mennos-desktop: ~/dotfiles/config/ssh/authorized_keys/mennos-desktop
|
||||||
|
homeserver-pc: ~/dotfiles/config/ssh/authorized_keys/homeserver-pc
|
||||||
|
target: ~/.ssh/authorized_keys
|
||||||
|
chmod: 600
|
||||||
|
|
||||||
# Zshrc
|
# Zshrc
|
||||||
zshrc:
|
zshrc:
|
||||||
source: ~/dotfiles/.zshrc
|
source: ~/dotfiles/.zshrc
|
||||||
@ -56,7 +64,7 @@ config:
|
|||||||
command: alacritty
|
command: alacritty
|
||||||
screenshot:
|
screenshot:
|
||||||
shortcut: Shift + Alt + 4
|
shortcut: Shift + Alt + 4
|
||||||
command: cosmic-screenshot --interactive
|
command: flameshot gui
|
||||||
missioncenter:
|
missioncenter:
|
||||||
shortcut: Ctrl + Shift + Escape
|
shortcut: Ctrl + Shift + Escape
|
||||||
command: flatpak run io.missioncenter.MissionCenter
|
command: flatpak run io.missioncenter.MissionCenter
|
||||||
@ -122,10 +130,10 @@ config:
|
|||||||
fd-find:
|
fd-find:
|
||||||
procs:
|
procs:
|
||||||
bottom:
|
bottom:
|
||||||
swhkd:
|
Simple-Wayland-HotKey-Daemon:
|
||||||
git_url: https://github.com/waycrate/swhkd.git
|
git_url: https://github.com/waycrate/swhkd.git
|
||||||
binary: Simple-Wayland-HotKey-Daemon
|
binary: Simple-Wayland-HotKey-Daemon
|
||||||
swhkd:
|
swhks:
|
||||||
git_url: https://github.com/waycrate/swhkd.git
|
git_url: https://github.com/waycrate/swhkd.git
|
||||||
binary: swhks
|
binary: swhks
|
||||||
|
|
||||||
@ -151,7 +159,6 @@ config:
|
|||||||
- vim
|
- vim
|
||||||
- sl
|
- sl
|
||||||
- jq
|
- jq
|
||||||
# - just
|
|
||||||
- libglvnd-dev
|
- libglvnd-dev
|
||||||
- libwayland-dev
|
- libwayland-dev
|
||||||
- libseat-dev
|
- libseat-dev
|
||||||
|
2
config/ssh/authorized_keys/mennos-desktop
Normal file
2
config/ssh/authorized_keys/mennos-desktop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# This is the authrorized_keys file for the user mennos-desktop
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM+sKpcREOUjwMMSzEWAso6830wbOi8kUxqpuXWw5gHr
|
2
config/ssh/authorized_keys/mennos-laptop
Normal file
2
config/ssh/authorized_keys/mennos-laptop
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# This is the authrorized_keys file for the user mennos-laptop
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM+sKpcREOUjwMMSzEWAso6830wbOi8kUxqpuXWw5gHr
|
Loading…
x
Reference in New Issue
Block a user