-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-installer
145 lines (130 loc) · 4.1 KB
/
custom-installer
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
#!/bin/bash
# check for elevated privileges
if [ "$EUID" -ne "0" ]; then
if [[ "$gksu" -eq "0" ]]; then
exec gksu "$0"
exit 0
elif [[ "$kdesu" -eq "0" ]]; then
exec kdesu "$0"
exit 0
else
echo "Cannot find appropiate way to run as root! Please report!" 1>&2
exit 1
fi
fi
# [key]="package-name_description"
declare -A APPS=(
[0]="aqualung_Music player"
[1]="frozen-bubble_Game"
[2]="gcolor2_Color selector"
[3]="gweled_Puzzle game"
[4]="minitube_Youtube"
[5]="neverball_Game"
[6]="qmmp_Music player"
[7]="shutter_For screenshots"
)
# [key]="app name"
declare -A APP_NAME=(
[0]="Aqualung"
[1]="Frozen Bubble"
[2]="Gcolor2"
[3]="Gweled"
[4]="Mini Tube"
[5]="Neverball"
[6]="Qmmp"
[7]="Shutter"
)
APP_TITLE="Install Apps"
function _checklock ()
{
# Checks for exclusive lock and wait until package managers are closed
while fuser /var/lib/dpkg/lock 2>&1 >/dev/null ; do
echo "# ! . . . . . . waiting for package manager(s) to close . . . . . . !" $"\n"
if [ "$(pidof synaptic)" ]; then
echo "# ! . . . . . . waiting for package manager(s) to close . . . . . . !" $"\nsynaptic"
fi
echo 1
sleep 1
echo 30
sleep 1
echo 60
sleep 1
if [ ! -z "$(pgrep gdebi-gtk)" ]; then
echo "# ! . . . . . . waiting for package manager(s) to close . . . . . . !" $"\ngdebi-gtk"
fi
echo 95
sleep 1
done | (if ! zenity --progress \
--window-icon="$ic" \
--title="$APP_TITLE - Waiting!" \
--percentage=20 \
--auto-close
then killall $(basename $0)
exit 0
fi)
}
_chklist()
{
for k in "${!APPS[@]}"; do
while read -a X; do
# Grab and set a var for the build.
if [ "${X[0]}" == "Installed:" ]; then
if [ "${X[1]}" == "(none)" ]; then
printf -v _VERSION "%s" ""
else
printf -v _VERSION "%s" "${X[1]}"
fi
break
fi
done <<< "$(apt-cache policy "${APPS[$k]%%_*}")"
printf "%s\n%s\n%s\n%s\n%s\n" "FALSE" "$k" "${APP_NAME[$k]}" "${APPS[$k]#*_}" "$_VERSION"
done
}
_main()
{
# Main dialog
choices=$( _chklist | zenity --title="$APP_TITLE" \
--width=520 \
--height=400 \
--text="Select to install" \
--list \
--column="Select" \
--column="Key" \
--column="Name" \
--column="Description" \
--column="Installed" \
--checklist \
--hide-column=2 \
--print-column=2 )
# If Cancel is clicked then exit
if [ "${?}" -ne "0" ]; then
exit 0
fi
if [[ ! "${choices}" =~ ^[0-9|]+$ ]]; then
zenity --info \
--title="$APP_TITLE" \
--text='Nothing was selected for installation.'
_main
fi
}
_main
pkg=()
IFS='|' read -a choices <<< "${choices}"
for choice in "${choices[@]}"; do
pkg+=( "${APPS[$choice]%%_*}" )
done
# Check for exclusive lock
_checklock
stdbuf -oL apt-get -y --force-yes install "${pkg[@]}" --show-progress \
| stdbuf -oL sed -n -e 's/Progress:[ ]\[//;s/%\]//;s/^[ \t]*//p;/^[a-zA-Z]/s/^/#/p' \
| zenity --progress --title="Installing - Please wait" --auto-close
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
zenity --error \
--title="$APP_TITLE" \
--text="Something went wrong while installing!"
exit 1
fi
zenity --info \
--title="$APP_TITLE" \
--text="Successfully installed."
exit 0