-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-installer.sh
executable file
·70 lines (59 loc) · 2.15 KB
/
generate-installer.sh
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
#!/bin/bash
#
# HOW TO USE:
#
# ./generate-installer.sh irydium-chemistry-lab irydium-chemistry-lab "Irydium Chemistry Lab"
canonicalName=$1
pkgName=$2
humanName=$3
echo "Generating launcher..."
cat << EOF > deb_package/usr/share/applications/$canonicalName-installer.desktop
[Desktop Entry]
Name=$humanName
Exec=/usr/bin/$pkgName-installer
Icon=$pkgName-installer
Terminal=false
Type=Application
StartupNotify=true
NoDisplay=false
EOF
echo "Generating binary..."
cat << EOF > deb_package/usr/bin/$pkgName-installer
#!/bin/bash
pkexec /usr/share/appsedu/$pkgName.sh 2>&1 >/dev/null | \\
zenity --progress --pulsate --no-cancel --auto-close --title="$humanName" --width=450 \\
--text="Espere um pouco. Estamos instalando o app..."
$pkgName
EOF
sudo chmod +x deb_package/usr/bin/$pkgName-installer
echo "Generating installer..."
cat << EOF > deb_package/usr/share/appsedu/$pkgName.sh
#!/bin/bash
apt update
apt install $pkgName -y
hadInstalled=\$(apt list $pkgName | grep instal | wc -l)
if [ "\$hadInstalled" == "1" ]; then
sed -i '/NoDisplay=/c\NoDisplay=true' /usr/share/applications/$canonicalName-installer.desktop
sed -i '/Categories=/d' /usr/share/applications/$canonicalName.desktop
fi
EOF
sudo chmod +x deb_package/usr/share/appsedu/$pkgName.sh
echo "Generating policy..."
cat << EOF > deb_package/usr/share/polkit-1/actions/io.github.appsedu.$pkgName.policy
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<action id="io.github.appsedu.$pkgName.pkexec">
<description>Install $humanName</description>
<message>Authentication is required to run the superuser</message>
<icon_name></icon_name>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/share/appsedu/$pkgName.sh</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
EOF