Add auto-updater
This commit is contained in:
parent
22d38f2cea
commit
65c25a8345
23
InitMate.sh
23
InitMate.sh
|
@ -15,6 +15,28 @@ check_root() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Function to check for updates
|
||||
check_for_updates() {
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
if [ -d "$SCRIPT_DIR/.git" ]; then
|
||||
log "Checking for updates..."
|
||||
cd "$SCRIPT_DIR" || exit
|
||||
git fetch
|
||||
LOCAL=$(git rev-parse @)
|
||||
REMOTE=$(git rev-parse "@{u}")
|
||||
if [ "$LOCAL" != "$REMOTE" ]; then
|
||||
log "Updates available. Pulling the latest changes..."
|
||||
git pull
|
||||
log "InitMate updated. Please rerun."
|
||||
exit 0
|
||||
else
|
||||
log "No updates available."
|
||||
fi
|
||||
else
|
||||
log "This is not a Git repository. Skipping update check."
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to detect the OS and package manager
|
||||
detect_os() {
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
|
@ -199,6 +221,7 @@ prompt_reboot() {
|
|||
|
||||
# Main script execution
|
||||
check_root
|
||||
check_for_updates
|
||||
detect_os
|
||||
log "Detected OS: $OS, Package Manager: $PKG_MANAGER"
|
||||
if ! prompt_yes_no "Is this correct?"; then
|
||||
|
|
Loading…
Reference in New Issue
Block a user