yage
e2c6007a65
===================================================================== --- Changes ------------------------------ - system/config/symlink ) now copies the existing config from the current system if the "source" config does not exist (init from local) - allowed implementation of group-custom scwrypt listing function GET_AVAILABLE_SCWRYPTS__<group-name> --- Bug Fixes ---------------------------- - fixed a bug where custom runstring operators were ignored
48 lines
1.3 KiB
Bash
Executable File
48 lines
1.3 KiB
Bash
Executable File
#!/bin/zsh
|
|
DEPENDENCIES+=()
|
|
REQUIRED_ENV+=()
|
|
|
|
use system/config
|
|
|
|
CHECK_ENVIRONMENT
|
|
#####################################################################
|
|
|
|
SETUP_SYMLINKS() {
|
|
while read SYMLINK
|
|
do
|
|
SETUP_SYMLINK $(echo $SYMLINK | awk '{print $1;}') $(echo $SYMLINK | awk '{print $2}')
|
|
done < <(echo $SYMLINKS | sed -n '/^[^#]/p')
|
|
}
|
|
|
|
SETUP_SYMLINK() {
|
|
[ ! $2 ] && FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG'
|
|
|
|
local SOURCE_CONFIG="$1"
|
|
local TARGET_CONFIG="$HOME/.config/$2"
|
|
|
|
[ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && [ -f "$TARGET_CONFIG" ] && {
|
|
INFO 'SOURCE_CONFIG is not tracked; copying from TARGET_CONFIG'
|
|
mkdir -p "$(dirname "$SOURCE_CONFIG")"
|
|
cp "$TARGET_CONFIG" "$SOURCE_CONFIG"
|
|
}
|
|
[ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && {
|
|
WARNING "no such file or directory '$SOURCE_CONFIG'"
|
|
return 0
|
|
}
|
|
|
|
[ ! -d $(dirname "$TARGET_CONFIG") ] && mkdir -p $(dirname "$TARGET_CONFIG")
|
|
|
|
[[ $SAFE_SYMLINKS -eq 1 ]] \
|
|
&& mv "$TARGET_CONFIG" "$TARGET_CONFIG.bak" >/dev/null 2>&1
|
|
|
|
rm "$TARGET_CONFIG" >/dev/null 2>&1
|
|
|
|
ln -s "$SOURCE_CONFIG" "$TARGET_CONFIG" \
|
|
&& SUCCESS "successfully linked '$(basename $(dirname $TARGET_CONFIG))/$(basename $TARGET_CONFIG)'" \
|
|
|| FAIL 3 "failed to create link '$TARGET_CONFIG'" \
|
|
;
|
|
}
|
|
|
|
#####################################################################
|
|
SETUP_SYMLINKS $@
|