Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
updated update function
Browse files Browse the repository at this point in the history
  • Loading branch information
snwh committed May 20, 2018
1 parent a364dc4 commit 4335a37
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 33 deletions.
2 changes: 1 addition & 1 deletion functions/add_repositories
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function add_launchpad_ppa() {
echo_message info "Adding ${1} PPA repository..."
elevate_privilege "add-apt-repository -y ppa:${2}"
# Update repository information
elevate_privilege "apt update -y"
elevate_privilege "apt update -qq -y"
# Done
echo_message success "Repository added."
else
Expand Down
11 changes: 5 additions & 6 deletions functions/install_functions
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ function install_remote_package() {
fi
}


# Install flatpak package
function install_flatpak_package() {
# echo_message header "Starting 'install_flatpak_package' function..."
Expand All @@ -159,17 +158,17 @@ function install_flatpak_package() {
flatpak install -y ${2} ${3}
# Finished
echo_message success "$1 is installation complete."
whiptail --title "Finished" --msgbox "Installation of ${1} Flatpak complete." 8 64
whiptail --title "Finished" --msgbox "Installation of ${1^} (Flatpak) complete." 8 64
$4
else
# Cancelled
echo_message info "Installation of ${1} cancelled."
echo_message info "Installation of ${1^} cancelled."
$4
fi
else
# Already installed
echo_message info "${3} is already installed."
whiptail --title "Installed" --msgbox "The Flatpak for ${1} is already installed." 8 64
whiptail --title "Installed" --msgbox "${1^} is already installed." 8 64
$4
fi
}
Expand All @@ -190,7 +189,7 @@ function install_snap_package() {
elevate_privilege "snap install ${1}"
# Finished
echo_message success "'${1}' is installation complete."
whiptail --title "Finished" --msgbox "Installation of ${1^} Snap complete." 8 64
whiptail --title "Finished" --msgbox "Installation of ${1^} (Snap) complete." 8 64
$3
else
# Cancelled
Expand All @@ -200,7 +199,7 @@ function install_snap_package() {
else
# Already installed
echo_message info "${1} is already installed."
whiptail --title "Installed" --msgbox "The Snap for ${1^} is already installed." 8 64
whiptail --title "Installed" --msgbox "${1^} is already installed." 8 64
$3
fi
}
2 changes: 1 addition & 1 deletion functions/install_thirdparty
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash#
#!/bin/bash
#
# When adding (or removing) any functions remember to update
# the 'install_thirdparty' function below to reflect any changes you make
Expand Down
113 changes: 89 additions & 24 deletions functions/system_update
Original file line number Diff line number Diff line change
@@ -1,47 +1,112 @@
#!/bin/bash

# Perform system upgrade via apt
function system_update {
function update_system {
echo_message title "Performing system update..."
# Draw window
if (whiptail --title "System Update" --yesno "Check for system software updates?" 8 64) then
# Update repository information
echo_message info 'Updating repository information...'
# Admin privileges
elevate_privilege 'apt update -y'
elevate_privilege 'apt update -qq -y'
echo_message success 'Repository information updated.'
# Move on to package upgrade
system_upgrade
# Done
echo_message success 'System update complete.'
whiptail --title "Finished" --msgbox "System update complete." 8 64
# List upgrades
if [ $(apt list --upgradeable | wc -l) = 1 ]; then
# Cancelled
echo_message info "System is up to date."
whiptail --title "Finished" --msgbox "No updates available. System is up to date." 8 56
main
else
# Move on to package upgrade
if (eval `resize` && whiptail \
--title "System Upgrade" \
--yesno "Current list of packages to be updated: \n\n$(apt list --upgradeable) \n\nAre you sure you want proceed?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext ) then
# Upgrade
echo_message info 'Upgrading packages...'
elevate_privilege "apt dist-upgrade -y"
# Finished
echo_message success "System update complete."
whiptail --title "Finished" --msgbox "System update complete." 8 56
main
else
# Cancelled
echo_message info "System update cancelled."
main
fi
fi
else
# Cancelled
echo_message info "Installation of ${2} cancelled."
main
fi
}

# Perform system update
function system_upgrade {
echo_message title "Performing system upgrade..."
NAME="System Upgrade"
# Draw window
if (eval `resize` && whiptail \
--title "${NAME^}" \
--yesno "Current list of packages to be updated: \n\n$(apt list --upgradeable) \n\nAre you sure you want proceed?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext ) then
# Upgrade
echo_message info 'Upgrading packages...'
elevate_privilege "apt dist-upgrade -y"
# Check for snap updates
function update_snap_apps {
# check if flatpak is installed
check_package "snapd" system_update
# continue
echo_message info "Updating installed snap packages..."
elevate_privilege "snap refresh"
if [ $? = 0 ]; then
# Finished
echo_message success "$NAME complete."
whiptail --title "Finished" --msgbox "$NAME complete." 8 56
echo_message success "All snaps up to date."
whiptail --title "Finished" --msgbox "All snaps up to date." 8 56
main
else
# Cancelled
echo_message info "$NAME cancelled."
# Finished
echo_message success "Snap package update complete."
whiptail --title "Finished" --msgbox "Snap package update complete." 8 56
main
fi
}

# Check for flatpak updates
function update_flatpak_apps {
# check if flatpak is installed
check_package "flatpak" system_update
# continue
echo_message info "Updating installed flatpak packages..."
flatpak update
if [ $? = 0 ]; then
# Finished
echo_message success "All flatpaks up to date."
whiptail --title "Finished" --msgbox "All flatpaks up to date." 8 56
main
else
# Finished
echo_message success "Flatpak package update complete."
whiptail --title "Finished" --msgbox "Flatpak package update complete." 8 56
main
fi
}

# Perform system updates
function system_update {
# install
echo_message title "Starting system updates..."
# Draw window
UPDATE=$(eval `resize` && whiptail \
--notags \
--title "Install $NAME" \
--menu "\nWhat ${NAME,,} would you like to install?" \
--ok-button "Install" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'update_system' 'Update system' \
'update_snap_apps' 'Update Snap apps' \
'update_flatpak_apps' 'Update Flatpak apps' \
3>&1 1>&2 2>&3)

# check exit status
if [ $? = 0 ]; then
echo_message header "Starting '$UPDATE' function..."
$UPDATE
else
# Cancelled
echo_message info "System updates cancelled."
main
fi
}
2 changes: 1 addition & 1 deletion ubuntu-post-install-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function main {
--menu "\nWhat would you like to do?" \
--cancel-button "Quit" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'system_update' 'Perform system update' \
'system_update' 'Perform system updates' \
'install_favs' 'Install preferred applications' \
'install_favs_utils' 'Install preferred utilities' \
'install_favs_dev' 'Install preferred development tools' \
Expand Down

0 comments on commit 4335a37

Please sign in to comment.