This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
install
198 lines (155 loc) · 5.42 KB
/
install
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
194
195
196
197
198
if [ -f "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs" ] ; then
source "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs"
fi
export DIST_CODENAME=`lsb_release -c | awk '{print $2}'`
export DESKTOP_DIR="${XDG_DESKTOP_DIR:-$HOME/Desktop}"
export DOWNLOADS_DIR="${XDG_DOWNLOADS_DIR:-$HOME/Downloads}"
export PKG_ARCHIVE="${DOWNLOADS_DIR}/pkgarch"
mkdir -p "${PKG_ARCHIVE}"
#------------------------------------------------------------------------------------------------------
function preAuthRoot () {
if ! [ -z "${ROOT_PASS}" ] ; then
if eval "echo ${ROOT_PASS} | sudo -S printf ''" ; then return 0
else return 1
fi
fi
}
export -f preAuthRoot
#------------------------------------------------------------------------------------------------------
function show_message() {
echo ""
for MSG in "$@" ; do echo " ${MSG}" ; done
echo ""
}
export -f show_message
function exportdefvar() {
if ( ! [ "${!1}" ] && [ "$2" ] ) ; then eval "export $1=\"${2}\"" ; fi
}
export -f exportdefvar
SECONDS=0
function showElapsedTime() {
duration=${SECONDS}
show_message "$((${duration} / 60)) min. $((${duration} % 60)) sec. elapsed"
}
export -f showElapsedTime
function goto_exit() {
showElapsedTime
if ( [[ $# != 0 ]] && [[ $1 != 0 ]] ) ; then
show_message "ERROR CODE: $@"
exit $@
fi
}
export -f goto_exit
#------------------------------------------------------------------------------------------------------
SCRIPT_SRC_DIR="$(dirname "$(realpath -s "$0")")"
source /etc/os-release
if ! [ -z "$(cat /etc/os-release | grep "ID=neon")" ] ; then export IS_KDE_NEON=1 ; fi
if [[ $IS_KDE_NEON ]] ; then
export IFS='.'
read -r -a PLASMA_VERSION <<< $(plasmashell --version | grep plasma | cut -d ' ' -f2)
fi
if [[ `echo $XDG_CURRENT_DESKTOP` == "KDE" ]] ; then export IS_KDE=1 ; fi
#------------------------------------------------------------------------------------------------------
function update_system() {
preAuthRoot
sudo apt -f install -y
if [[ $IS_KDE_NEON ]] ; then
# KDE Neon
if ! ( pkcon refresh ) ; then
show_message "FAILED TO UPDATE SYSTEM (pkcon)"
goto_exit 1
fi
pkcon update -y
else
# Ubuntu
preAuthRoot
if ! ( sudo apt update && sudo apt upgrade -y ) ; then
show_message "FAILED TO UPDATE SYSTEM (apt)"
goto_exit 1
fi
fi
preAuthRoot
sudo apt -f install -y
return 0
}
function get_local() {
if ! [ -f "${PKG_ARCHIVE}/$1" ] ; then
mkdir -p "${PKG_ARCHIVE}"
if [ -d "${PKG_ARCHIVE}" ] ; then
if ( wget -nc -O "${PKG_ARCHIVE}/$1" "$2" ) ; then
return 0
fi
fi
show_message "FAILED TO GET PACKAGE $1"
goto_exit 1
fi
return 0
}
function install_local_solo_lpkg() {
PKG_NAME="$1"
if ! [ -f "${PKG_NAME}" ] ; then
if [ -f "${PKG_NAME}.deb" ] ; then PKG_NAME="${PKG_NAME}.deb";
elif [ -f "${PKG_NAME}.flatpakref" ] ; then PKG_NAME="${PKG_NAME}.flatpakref";
elif [ -f "${PKG_ARCHIVE}/${PKG_NAME}" ] ; then PKG_NAME="${PKG_ARCHIVE}/${PKG_NAME}";
elif [ -f "${PKG_ARCHIVE}/${PKG_NAME}.deb" ] ; then PKG_NAME="${PKG_ARCHIVE}/${PKG_NAME}.deb";
elif [ -f "${PKG_ARCHIVE}/${PKG_NAME}.flatpakref" ] ; then PKG_NAME="${PKG_ARCHIVE}/${PKG_NAME}.flatpakref";
elif [ -f "${PKG_ARCHIVE}/${PKG_NAME}.AppImage" ] ; then PKG_NAME="${PKG_ARCHIVE}/${PKG_NAME}.AppImage";
else unset PKG_NAME
fi
fi
if [[ -f "${PKG_NAME}" ]] ; then
preAuthRoot
AILEF="`whereis AppImageLauncher | awk '{print $2}'`"
if ( [[ "${PKG_NAME}" =~ ".AppImage" ]] && [ -f "${AILEF}" ] ) ; then
eval AppImageLauncher "${PKG_NAME}" &
return 0
elif ( sudo pkcon install-local "${PKG_NAME}" -y ) ; then
if [[ "${PKG_NAME}" =~ ".flatpakref" ]] ; then
preAuthRoot
sudo flatpak override "${PKG_NAME}" --filesystem=/media --filesystem=/mnt --filesystem=/run/media --filesystem=/run/mnt
fi
return 0;
fi
show_message "INSTALLATION WAS FAILED (AppImageLauncher, pkcon-local)"
goto_exit 1
fi
return 1;
}
function install_lpkg() {
REMOTE_PKGS=()
for LOCAL_PKG_NAME in "$@" ; do
if ! ( install_local_solo_lpkg "$LOCAL_PKG_NAME" ) ; then
REMOTE_PKGS+=("$LOCAL_PKG_NAME")
fi
done
if ! [[ -z "${REMOTE_PKGS[@]}" ]] ; then
preAuthRoot
AAAarg="-y"
if [[ "${APT_AUTO_ACCEPT}" == "n" ]] ; then unset AAAarg ; fi
if ! ( sudo apt install --install-recommends "${REMOTE_PKGS[@]}" "${AAAarg}" ) ; then
preAuthRoot
if ! ( sudo apt -f install "${AAAarg}" ) ; then
show_message "INSTALLATION WAS FAILED (apt)"
goto_exit 1
fi
fi
fi
return 0
}
function install_snap() {
for SNAP_PKG_NAME in "$@" ; do
preAuthRoot
if ! ( eval "sudo snap install $SNAP_PKG_NAME" ) ; then
show_message "INSTALLATION OF $SNAP_PKG_NAME WAS FAILED (snap)"
goto_exit 1
fi
done
}
function install_flatpak() {
for FPK_PKG_NAME in "$@" ; do
if ! ( eval "flatpak install flathub $FPK_PKG_NAME" ) ; then
show_message "INSTALLATION OF $FPK_PKG_NAME WAS FAILED (flatpak)"
goto_exit 1
fi
done
}