add update.sh
This commit is contained in:
parent
0be8988752
commit
80d2e5d361
13
init_user.sh
13
init_user.sh
@ -8,19 +8,6 @@ scriptdir=$(dirname $(realpath $0))
|
|||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
update_authorized_keys() {
|
|
||||||
[ ! -f ~/.ssh/authorized_keys ] && return
|
|
||||||
|
|
||||||
local public_keys=$(cat $scriptdir/files/authorized_keys)
|
|
||||||
while IFS= read -r public_key; do
|
|
||||||
[[ $public_key == \#* ]] && continue
|
|
||||||
if ! grep -q "$public_key" ~/.ssh/authorized_keys; then
|
|
||||||
echo "$public_key" >> ~/.ssh/authorized_keys
|
|
||||||
echo "Added public key to authorized_keys: $public_key"
|
|
||||||
fi
|
|
||||||
done <<< "$public_keys"
|
|
||||||
}
|
|
||||||
|
|
||||||
configure_ssh() {
|
configure_ssh() {
|
||||||
[ -f ~/.ssh/authorized_keys ] && return
|
[ -f ~/.ssh/authorized_keys ] && return
|
||||||
|
|
||||||
|
|||||||
10
run.sh
10
run.sh
@ -12,15 +12,7 @@ scriptdir=$(dirname $(realpath $0))
|
|||||||
|
|
||||||
git -C $scriptdir pull
|
git -C $scriptdir pull
|
||||||
|
|
||||||
update_file $scriptdir/files/zsh/00-init.zsh ~/.oh-my-zsh/custom/00-init.zsh
|
$scriptdir/update.sh
|
||||||
update_file $scriptdir/files/zsh/10-theme.zsh ~/.oh-my-zsh/custom/10-theme.zsh
|
|
||||||
update_file $scriptdir/files/zsh/20-function.zsh ~/.oh-my-zsh/custom/20-function.zsh
|
|
||||||
update_file $scriptdir/files/zsh/50-alias.zsh ~/.oh-my-zsh/custom/50-alias.zsh
|
|
||||||
update_file $scriptdir/files/zsh/80-env.zsh ~/.oh-my-zsh/custom/80-env.zsh
|
|
||||||
update_file $scriptdir/files/zsh/81-proxy.zsh ~/.oh-my-zsh/custom/81-proxy.zsh
|
|
||||||
update_file $scriptdir/files/zsh/90-other.zsh ~/.oh-my-zsh/custom/90-other.zsh
|
|
||||||
update_file $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/ys-simple.zsh-theme
|
|
||||||
update_authorized_keys
|
|
||||||
|
|
||||||
if [ "$1" = "update" ]; then
|
if [ "$1" = "update" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
40
update.sh
Executable file
40
update.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
scriptdir=$(dirname $(realpath $0))
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
update_file() {
|
||||||
|
local A="$1"
|
||||||
|
local B="$2"
|
||||||
|
|
||||||
|
if [ -f "$A" ] && [ -f "$B" ] && [ "$(cat "$A")" != "$(cat "$B")" ]; then
|
||||||
|
cp "$A" "$B"
|
||||||
|
echo "File $B has been updated."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update_authorized_keys() {
|
||||||
|
[ ! -f ~/.ssh/authorized_keys ] && return
|
||||||
|
|
||||||
|
local public_keys=$(cat $scriptdir/files/authorized_keys)
|
||||||
|
while IFS= read -r public_key; do
|
||||||
|
[[ $public_key == \#* ]] && continue
|
||||||
|
if ! grep -q "$public_key" ~/.ssh/authorized_keys; then
|
||||||
|
echo "$public_key" >> ~/.ssh/authorized_keys
|
||||||
|
echo "Added public key to authorized_keys: $public_key"
|
||||||
|
fi
|
||||||
|
done <<< "$public_keys"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
update_file $scriptdir/files/zsh/00-init.zsh ~/.oh-my-zsh/custom/00-init.zsh
|
||||||
|
update_file $scriptdir/files/zsh/10-theme.zsh ~/.oh-my-zsh/custom/10-theme.zsh
|
||||||
|
update_file $scriptdir/files/zsh/20-function.zsh ~/.oh-my-zsh/custom/20-function.zsh
|
||||||
|
update_file $scriptdir/files/zsh/50-alias.zsh ~/.oh-my-zsh/custom/50-alias.zsh
|
||||||
|
update_file $scriptdir/files/zsh/80-env.zsh ~/.oh-my-zsh/custom/80-env.zsh
|
||||||
|
update_file $scriptdir/files/zsh/81-proxy.zsh ~/.oh-my-zsh/custom/81-proxy.zsh
|
||||||
|
update_file $scriptdir/files/zsh/90-other.zsh ~/.oh-my-zsh/custom/90-other.zsh
|
||||||
|
update_file $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/ys-simple.zsh-theme
|
||||||
|
update_authorized_keys
|
||||||
10
utils.sh
10
utils.sh
@ -30,16 +30,6 @@ check_google_access() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_file() {
|
|
||||||
local A="$1"
|
|
||||||
local B="$2"
|
|
||||||
|
|
||||||
if [ -f "$A" ] && [ -f "$B" ] && [ "$(cat "$A")" != "$(cat "$B")" ]; then
|
|
||||||
cp "$A" "$B"
|
|
||||||
echo "File $B has been updated."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
confirm_action() {
|
confirm_action() {
|
||||||
local prompt="$1"
|
local prompt="$1"
|
||||||
local default_response="$2"
|
local default_response="$2"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user