self-update: pull remote and re-exec if script changed before deploying
This commit is contained in:
parent
d85b6ca29a
commit
3cb52999e7
20
setup_env.sh
20
setup_env.sh
@ -119,8 +119,26 @@ deploy_nvim() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Pull latest from remote and re-exec if the script itself changed
|
||||||
|
self_update() {
|
||||||
|
if ! git -C "$(pwd)" rev-parse --is-inside-work-tree &>/dev/null; then
|
||||||
|
echo "Warning: not a git repo, skipping self-update"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "Pulling latest from remote..."
|
||||||
|
local before after
|
||||||
|
before=$(git rev-parse HEAD)
|
||||||
|
git pull
|
||||||
|
after=$(git rev-parse HEAD)
|
||||||
|
if [ "$before" != "$after" ]; then
|
||||||
|
echo "setup_env.sh updated — re-running with latest version..."
|
||||||
|
exec "$0" "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Main script
|
# Main script
|
||||||
main() {
|
main() {
|
||||||
|
self_update "$@"
|
||||||
install_packages
|
install_packages
|
||||||
install_tpm
|
install_tpm
|
||||||
install_vundle
|
install_vundle
|
||||||
@ -131,5 +149,5 @@ main() {
|
|||||||
echo "Setup complete! Please restart your shell or run 'source ~/.bashrc' for changes to take effect."
|
echo "Setup complete! Please restart your shell or run 'source ~/.bashrc' for changes to take effect."
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main "$@"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user