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

Commit

Permalink
consistency in install syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
snwh committed May 21, 2018
1 parent 4955183 commit d5e3365
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 71 deletions.
6 changes: 1 addition & 5 deletions functions/apps/oracle-java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ function install_oracle_java {
# check exit status
if [ $? = 0 ]; then
# Install package
install_package "$PACKAGE" "$NAME" install_thirdparty
# Done
echo_message success "Installation of '$PACKAGE' complete."
whiptail --title "Finished" --msgbox "Installation of $NAME complete." 8 64
install_thirdparty
install_package "$NAME" "$PACKAGE" install_thirdparty
else
# Cancelled
echo_message info "Installation of $NAME cancelled."
Expand Down
8 changes: 4 additions & 4 deletions functions/install_favs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
# Install preferred apps
function install_favs {
# Update the list of packages in 'data/favs.list' to suit your preferences
install_from_list favs "preferred applications" main
install_from_list "preferred applications" "favs" main
}

# Install preferred development tools
function install_favs_dev {
# Update the list of packages in 'data/favs-dev.list' to suit your preferences
install_from_list favs-dev "preferred development tools" main
install_from_list "preferred development tools" "favs-dev" main
}

# Install preferred utilities
function install_favs_utils {
# Update the list of packages in 'data/favs-utils.list' to suit your preferences
install_from_list favs-utils "preferred utilities" main
install_from_list "preferred utilities" "favs-utils" main
}

# Install preferred GNOME apps
function install_codecs {
install_package ubuntu-restricted-extras "multimedia codecs" main
install_package "multimedia codecs" "ubuntu-restricted-extras" main
}
2 changes: 1 addition & 1 deletion functions/install_flatpak_apps
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function install_flathub_app() {
echo_message header "Starting 'install_flathub_app' function..."
# check if flathub repo is added
check_flatpak_repo "flathub" "https://flathub.org/repo/flathub.flatpakrepo" install_flatpak_apps
#install_flatpak_package "Name" "source" "com.package.Name" return_function
#install_flatpak_package "Name" "remote" "com.package.Name" return_function
install_flatpak_package $1 "flathub" $2 install_flatpak_apps
}

Expand Down
4 changes: 2 additions & 2 deletions functions/install_fonts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Install preferred fonts
function install_favs_fonts {
# Update the list of packages in 'data/favs-fonts.list' to suit your preferences
install_from_list favs-fonts "preferred fonts" install_fonts
install_from_list "preferred fonts" "favs-fonts" install_fonts
}

# Install Microsoft Core Fonts
function install_mscorefonts {
# Update the list of packages in 'data/favs-fonts.list' to suit your preferences
install_package ttf-mscorefonts-installer "Microsoft Core Fonts" install_fonts
install_package "Microsoft Core Fonts" "ttf-mscorefonts-installer" install_fonts
}

# Install Fonts
Expand Down
107 changes: 56 additions & 51 deletions functions/install_functions
Original file line number Diff line number Diff line change
@@ -1,88 +1,91 @@
#!/bin/bash

# Install single package
# ${1} = Name, ${2} = paclage, ${3} = return_function
function install_package() {
echo_message header "Starting 'install_package' function..."
# If package is not installed
if [ $(check_package_installed $PACKAGE) != 0 ]; then
echo_message info "${1} is not installed. Installing..."
if [ $(check_package_installed ${2}) != 0 ]; then
echo_message info "${2} is not installed. Installing..."
if (whiptail \
--title "Install ${2^}" \
--yesno "Proceed with installation of ${2^}?" 8 64) then
--title "Install ${1^}" \
--yesno "Proceed with installation of ${1^}?" 8 64) then
# Install
echo_message info "Installing package '${1}'..."
echo_message info "Installing package '${2}'..."
# Admin privileges
elevate_privilege "apt install -y ${1}"
elevate_privilege "apt install -y ${2}"
# Finished
echo_message success "Installation of package '${1}' is complete."
whiptail --title "Finished" --msgbox "Installation of ${2} complete." 8 64
echo_message success "Installation of package '${2}' is complete."
whiptail --title "Finished" --msgbox "Installation of ${1} complete." 8 64
# return
$3
${3}
else
# Cancelled
echo_message info "Installation of ${1} cancelled."
# return
$3
${3}
fi
else
# Already installed
echo_message info "Package '${2}' is already installed."
whiptail --title "Finished" --msgbox "Installation of ${2} is already complete." 8 64
whiptail --title "Finished" --msgbox "Installation of ${1} is already complete." 8 64
# return
$3
${3}
fi
}

# Install single remote package
# ${1} = Name, ${2} = package, ${3} = https://remote.example.com/, ${4} = return_function
function install_remote_package() {
echo_message header "Starting 'install_remote_package' function..."
# If package is not installed
if [ $(check_package_installed $PACKAGE) != 0 ]; then
echo_message info "$1 is not installed."
if [ $(check_package_installed ${2}) != 0 ]; then
echo_message info "${1} is not installed."
# Download Debian file that matches system architecture
case `uname -i` in
i386|i486|i586|i686)
# Download 32 bit package
echo_message info "Downloading remote package '${2}_i386.deb' from '$3'..."
echo_message info "Downloading remote package '${2}_i386.deb' from '${3}'..."
curl -O ${3}/${2}_i386.deb
;;
x86_64)
# Download 64 bit package
echo_message info "Downloading remote package '${2}_amd64.deb' from '$3'..."
echo_message info "Downloading remote package '${2}_amd64.deb' from '${3}'..."
curl -O ${3}/${2}_amd64.deb
;;
*)
whiptail --title "Error." --msgbox "No remote packages available to download." 8 64
$4
${4}
;;
esac
# Install package(s)
echo_message info "Installing '$2' package..."
elevate_privilege "dpkg -i $2*.deb"
echo_message info "Installing '${2}' package..."
elevate_privilege "dpkg -i ${2}*.deb"
# Install depencies, if any
echo_message info "Correcting any dependency errors..."
elevate_privilege "apt install -fy"
# Cleanup and finish
rm $2*.deb
rm ${2}*.deb
# Done
echo_message success "Installation of $1 complete."
whiptail --title "Finished" --msgbox "Installation of $1 complete." 8 64
$4
echo_message success "Installation of ${1} complete."
whiptail --title "Finished" --msgbox "Installation of ${1} complete." 8 64
${4}
else
# Already installed
echo_message info "$1 already installed."
whiptail --title "Finished" --msgbox "$1 is already installed." 8 64
$4
echo_message info "${1} already installed."
whiptail --title "Finished" --msgbox "${1} is already installed." 8 64
${4}
fi
}


# Install from list
# ${1} = Name, ${2} = list-name, ${3} = return_function
function install_from_list() {
# echo_message header "Starting 'install_from_list' function..."
echo_message title "Starting installation of ${2}..."
echo_message title "Starting installation of ${1}..."
# Variables
LIST=$(dirname "$0")'/data/'${1}'.list'
LIST=$(dirname "$0")'/data/'${2}'.list'
# Draw window
if (eval `resize` && whiptail \
--title "Install ${2^}" \
Expand All @@ -108,21 +111,22 @@ function install_from_list() {
fi
done
# Finished
echo_message success "Installation of ${2} complete."
whiptail --title "Finished" --msgbox "Installation of ${2} is complete." 8 56
$3
echo_message success "Installation of ${1} complete."
whiptail --title "Finished" --msgbox "Installation of ${1} is complete." 8 56
${3}
else
# Cancelled
echo_message info "Installation of ${2} cancelled."
$3
echo_message info "Installation of ${1} cancelled."
${3}
fi
}

# Install flatpak package
# ${1} = Name, ${2} = remote, ${3} = com.package.Name, ${4} = return_function
function install_flatpak_package() {
# echo_message header "Starting 'install_flatpak_package' function..."
# If package is not installed
if [ $(flatpak list | grep $3 &> /dev/null; echo $?) = 1 ]; then
if [[ $(flatpak list | grep ${3} &> /dev/null; echo $?) != 1 ]]; then
echo_message info "${1} is not installed. Installing..."
if (whiptail \
--title "Install ${1}" \
Expand All @@ -131,48 +135,49 @@ function install_flatpak_package() {
echo_message info "Installing flatpak '${3}'..."
flatpak install -y ${2} ${3}
# Finished
echo_message success "$1 is installation complete."
echo_message success "Installation of '${3}' is complete."
whiptail --title "Finished" --msgbox "Installation of ${1^} (Flatpak) complete." 8 64
$4
${4}
else
# Cancelled
echo_message info "Installation of ${1^} cancelled."
$4
${4}
fi
else
# Already installed
echo_message info "Flatpak '${3}' is already installed."
whiptail --title "Installed" --msgbox "${1^} is already installed." 8 64
$4
${4}
fi
}

# Install snap package
# ${1} = Name, ${2} = package, ${3} = return_function
function install_snap_package() {
# echo_message header "Starting 'install_snap_package' function..."
# If package is not installed
if [ $(snap list | grep $1 &> /dev/null; echo $?) = 1 ]; then
if [[ $(snap list | grep ${1} &> /dev/null; echo $?) != 1 ]]; then
echo_message info "${1} is not installed. Installing..."
if (whiptail \
--title "Install ${1^}" \
--yesno "The snap package for ${1^} is not installed. \n\nProceed with installation of '${1}'?" 10 64) then
--title "Install ${1}" \
--yesno "The snap package for ${1} is not installed. \n\nProceed with installation of '${2}'?" 10 64) then
# Install
echo_message info "Installing snap '${1}'..."
echo_message info "Installing snap package '${2}'..."
# Admin privileges
elevate_privilege "snap install ${1}"
elevate_privilege "snap install ${2}"
# Finished
echo_message success "'${1}' is installation complete."
whiptail --title "Finished" --msgbox "Installation of ${1^} (Snap) complete." 8 64
$3
echo_message success "Installation of '${2}' is complete."
whiptail --title "Finished" --msgbox "Installation of ${1} is complete." 8 64
${3}
else
# Cancelled
echo_message info "Installation of ${1^} cancelled."
$3
echo_message info "Installation of ${1} cancelled."
${3}
fi
else
# Already installed
echo_message info "Snap '${1}' is already installed."
whiptail --title "Installed" --msgbox "${1^} is already installed." 8 64
$3
echo_message info "Snap package '${2}' is already installed."
whiptail --title "Installed" --msgbox "${1} is already installed." 8 64
${3}
fi
}
4 changes: 2 additions & 2 deletions functions/install_gnome
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Install GNOME Core Apps
function install_gnome_apps {
# Update the list of packages in 'data/gnome-apps.list' to suit your preferences
install_from_list gnome-apps "preferred GNOME apps" install_gnome
install_from_list "preferred GNOME apps" "gnome-apps" install_gnome
}

# Install GNOME Shell Extensions
function install_shell_extensions {
# Update the list of packages in 'data/gnome-shell-extensions.list' to suit your preferences
install_from_list gnome-shell-extensions "preferred GNOME Shell extensions" install_gnome
install_from_list "preferred GNOME Shell extensions" "gnome-shell-extensions" install_gnome
}

# Install Codecs
Expand Down
12 changes: 6 additions & 6 deletions functions/install_snap_apps
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ function install_snap_apps {
'install_snap_inkscape' 'Inkscape' \
'install_snap_slack' 'Slack' \
'install_snap_spotify' 'Spotify' \
'install_snap_sublime' 'Sublime Text' \
'install_snap_sublime' 'Sublime Text 3' \
3>&1 1>&2 2>&3)

case "${SNAPS}" in
install_snap_atom)
# install Atom text editor
install_snap_package "atom" install_snap_apps
install_snap_package "Atom" "atom" install_snap_apps
;;
install_snap_inkscape)
# install Inkscape
install_snap_package "inkscape" install_snap_apps
install_snap_package "Inkscape" "inkscape" install_snap_apps
;;
install_snap_slack)
# install Slack
install_snap_package "slack" install_snap_apps
install_snap_package "Slack" "slack" install_snap_apps
;;
install_snap_spotify)
# install Spotify
install_snap_package "spotify" install_snap_apps
install_snap_package "Spotify" "spotify" install_snap_apps
;;
install_snap_sublime)
# install Sublime Text
install_snap_package "sublime-text" install_snap_apps
install_snap_package "Sublime Text 3" "sublime-text" install_snap_apps
;;
*)
# cancel
Expand Down

0 comments on commit d5e3365

Please sign in to comment.