mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 08:46:59 +08:00
install.sh: rerun when updated (#25)
* install.sh: rerun when updated * update ci
This commit is contained in:
parent
9a7f0b1b06
commit
995899f3a3
17
.update.sh
17
.update.sh
|
@ -3,12 +3,13 @@
|
|||
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||
THIS_FILE=$(basename "${BASH_SOURCE}")
|
||||
source "$THIS_DIR/tools/common.sh"
|
||||
DFS_ENABLE_RET=${DFS_ENABLE_RET:-0}
|
||||
|
||||
# get the specified commit id
|
||||
dfs_commit=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id)
|
||||
if [[ ${#dfs_commit} != 40 ]]; then
|
||||
DFS_COMMIT=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id)
|
||||
if [[ ${#DFS_COMMIT} != 40 ]]; then
|
||||
fmt_error "invalid commit id"
|
||||
post_log "ERROR" "$THIS_FILE" "invalid commit id: ${dfs_commit}"
|
||||
post_log "ERROR" "$THIS_FILE" "invalid commit id: ${DFS_COMMIT}"
|
||||
exit
|
||||
fi
|
||||
# fetch origin
|
||||
|
@ -20,16 +21,16 @@ if [[ -n "$(git status -s)" ]]; then
|
|||
exit
|
||||
fi
|
||||
# update
|
||||
if [[ "$(git rev-parse HEAD)" == "$dfs_commit" ]]; then
|
||||
if [[ "$(git rev-parse HEAD)" == "$DFS_COMMIT" ]]; then
|
||||
fmt_info "nothing to do"
|
||||
post_log "INFO" "$THIS_FILE" "nothing to do"
|
||||
else
|
||||
fmt_info "checking out to commit $dfs_commit ..."
|
||||
fmt_info "checking out to commit $DFS_COMMIT ..."
|
||||
if [[ -z "$DFS_DEV" ]]; then
|
||||
git -c advice.detachedHead=false checkout $dfs_commit
|
||||
post_log "INFO" "$THIS_FILE" "will check out to commit $DFS_COMMIT"
|
||||
git -c advice.detachedHead=false checkout $DFS_COMMIT
|
||||
cp ./.update.sh ./update.sh && chmod +x ./update.sh && exit $DFS_ENABLE_RET
|
||||
else
|
||||
fmt_warning "won't really checkout in dev mode"
|
||||
fi
|
||||
post_log "INFO" "$THIS_FILE" "will check out to commit $dfs_commit"
|
||||
cp ./.update.sh ./update.sh && chmod +x ./update.sh && exit
|
||||
fi
|
||||
|
|
|
@ -219,7 +219,11 @@ install_update(){
|
|||
cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh"
|
||||
chmod +x "${DOTFILES}/update.sh"
|
||||
fmt_note "running update.sh ..."
|
||||
${DOTFILES}/update.sh
|
||||
DFS_ENABLE_RET=1 ${DOTFILES}/update.sh
|
||||
if [[ $? == 1 ]]; then
|
||||
fmt_note "dfs updated. re-running install.sh ..."
|
||||
"${DOTFILES}/install.sh" && exit
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall_update(){
|
||||
|
@ -228,8 +232,8 @@ uninstall_update(){
|
|||
}
|
||||
|
||||
install(){
|
||||
preinstall_check
|
||||
install_update
|
||||
preinstall_check
|
||||
install_crontab
|
||||
install_file_content
|
||||
install_symlink
|
||||
|
|
|
@ -34,6 +34,14 @@ dfs version
|
|||
test `git rev-parse HEAD` = `curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id`
|
||||
|
||||
# clean
|
||||
dfs cd
|
||||
git reset --hard $DFS_VERSION
|
||||
|
||||
# then check install.sh
|
||||
./install.sh -l
|
||||
dfs version
|
||||
test `git rev-parse HEAD` = `curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id`
|
||||
|
||||
# clean
|
||||
git reset --hard $DFS_VERSION
|
||||
|
||||
set +x
|
Loading…
Reference in New Issue
Block a user