getdfs: install for another user using -u <uname>

This commit is contained in:
xiongdian.me 2023-01-05 22:42:49 +08:00
parent c5de9c9e65
commit 320cf6c206

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
DFS_USER=$(whoami)
ARG="" ARG=""
GOT_OPTS=() GOT_OPTS=()
while [[ $# > 0 || -n "$ARG" ]]; do while [[ $# > 0 || -n "$ARG" ]]; do
@ -32,9 +33,7 @@ while [[ $# > 0 || -n "$ARG" ]]; do
done done
# install # install
if [[ -n "$DFS_USER" ]]; then su $DFS_USER << EOF
su $DFS_USER
fi
cd cd
if [[ ! -f ~/dotfiles/install.sh ]]; then if [[ ! -f ~/dotfiles/install.sh ]]; then
git clone https://gitee.com/dictxiong/dotfiles git clone https://gitee.com/dictxiong/dotfiles
@ -46,5 +45,6 @@ if [[ "$DFS_SECURE" == "1" ]]; then
git -c advice.detachedHead=false checkout $(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id) git -c advice.detachedHead=false checkout $(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id)
cd cd
fi fi
./dotfiles/install.sh "${GOT_OPTS[@]}" ./dotfiles/install.sh ${GOT_OPTS[@]}
zsh -c "source ~/.zshrc" zsh -c "source ~/.zshrc"
EOF