This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
/
install_functions
executable file
·193 lines (183 loc) · 5.62 KB
/
install_functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
# Install single package function
#
# ${1} = Name
# ${2} = package-name
# ${3} = return_function
function install_package() {
echo_message header "Starting 'install_package' function..."
# If package is not installed
if [ $(check_package_installed ${2}) != 0 ]; then
echo_message info "${2} is not installed. Installing..."
if (whiptail \
--title "Install ${1^}" \
--yesno "Proceed with installation of ${1^}?" 8 56) then
# Install
echo_message info "Installing package '${2}'..."
# Admin privileges
superuser_do "dnf install -y ${2}"
# Finished
echo_message success "Installation of package '${2}' is complete."
whiptail --title "Finished" --msgbox "Installation of ${1} complete." 8 56
# return
${3}
else
# Cancelled
echo_message info "Installation of ${1} cancelled."
# return
${3}
fi
else
# Already installed
echo_message info "Package '${2}' is already installed."
whiptail --title "Finished" --msgbox "Installation of ${1} is already complete." 8 56
# return
${3}
fi
}
# Install single remote package function
#
# ${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 ${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.rpm' from '${3}'..."
superuser_do "dnf --nogpgcheck install -y ${3}/${2}i386.rpm"
;;
x86_64)
# Download 64 bit package
echo_message info "Downloading remote package '${2}x86_64.rpm' from '${3}'..."
superuser_do "dnf --nogpgcheck install -y ${3}/${2}x86_64.rpm"
;;
*)
whiptail --title "Error." --msgbox "No remote packages available to download." 8 56
${4}
;;
esac
# Cleanup and finish
rm ${2}*.rpm
# Done
echo_message success "Installation of ${1} complete."
whiptail --title "Finished" --msgbox "Installation of ${1} complete." 8 56
${4}
else
# Already installed
echo_message info "${1} already installed."
whiptail --title "Finished" --msgbox "${1} is already installed." 8 56
${4}
fi
}
# Install single remote package from a URL function
#
# ${1} = Name
# ${2} = package-name
# ${3} = https://remote.example.com/package.rpm
# ${4} = return_function
function install_remote_package_from_url() {
echo_message header "Starting 'install_remote_package_from_url' function..."
# If package is not installed
if [ $(check_package_installed ${2}) != 0 ]; then
echo_message info "${1} is not installed."
# Download RPM package from supplied URL
echo_message info "Downloading remote package from '${3}'..."
superuser_do "dnf --nogpgcheck install -y ${3}"
# Cleanup and finish
rm ${2}*.rpm
# Done
echo_message success "Installation of ${1} complete."
whiptail --title "Finished" --msgbox "Installation of ${1} complete." 8 56
${4}
else
# Already installed
echo_message info "${1} already installed."
whiptail --title "Finished" --msgbox "${1} is already installed." 8 56
${4}
fi
}
# Install from list function
#
# ${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 ${1}..."
# Variables
LIST=$(dirname "$0")'/data/'${2}'.list'
# Draw window
if (eval `resize` && whiptail \
--title "Install ${2^}" \
--yesno "Current list of packages that will be installed: \n\n$(cat ${LIST}) \n\nWould you like to proceed?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext \
3>&1 1>&2 2>&3) then
# Install loop
for PACKAGE in $(cat $LIST); do
# If package is not installed
if [ $(check_package_installed $PACKAGE) != 0 ]; then
# Install package
echo_message warning "Package '$PACKAGE' is not installed. Installing..."
# Admin privileges
superuser_do "dnf install -y $PACKAGE"
# Check if failed
if [[ $? != 0 ]]; then
echo_message error "Error installing '$PACKAGE'."
fi
else
# Show already installed message
echo_message info "Package '$PACKAGE' is installed."
fi
done
# Finished
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 ${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 $?) != 0 ]]; then
echo_message info "${1} is not installed. Installing..."
if (whiptail \
--title "Install ${1}" \
--yesno "The flatpak package for ${1} is not installed. \n\nProceed with installation of '${3}'?" 10 64) then
# Install
echo_message info "Installing flatpak '${3}'..."
# Configured to install for --user
flatpak install --user -y ${2} ${3}
# Finished
echo_message success "Installation of '${3}' is complete."
whiptail --title "Finished" --msgbox "Installation of ${1^} (Flatpak) complete." 8 56
${4}
else
# Cancelled
echo_message info "Installation of ${1^} cancelled."
${4}
fi
else
# Already installed
echo_message info "Flatpak '${3}' is already installed."
whiptail --title "Installed" --msgbox "${1^} is already installed." 8 56
${4}
fi
}