This repository has been archived by the owner on Mar 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_install.sh
executable file
·146 lines (112 loc) · 4.1 KB
/
post_install.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
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
#!/bin/bash
echo -e '\n\n'
#Create PiKISS GUI folder in share
datadir="${MESON_INSTALL_PREFIX}/share/pikiss-gui/"
mkdir $datadir
#Create PiKISS GUI menuentry
echo 'Creating PiKISS GUI menuentry...'
menuentrypath="${MESON_INSTALL_PREFIX}/share/applications/"
execpath="${MESON_INSTALL_PREFIX}/bin/pikiss-gui"
iconpath="${MESON_INSTALL_PREFIX}/share/icons/pikiss-gui.png"
cat << EOF > ${menuentrypath}pikiss-gui.desktop
[Desktop Entry]
Name=PiKISS GUI
GenericName=PiKISS
Comment=GTK frontend for PiKISS
Categories=Utility;
Exec=${execpath}
Icon=${iconpath}
Terminal=false
Type=Application
StartupNotify=true
EOF
chmod a+x "${menuentrypath}pikiss-gui.desktop"
echo -e 'PiKISS GUI menuentry created successfully.\n'
#Create App import script
#Gettig configs
getopt(){
grep $1 "${MESON_BUILD_ROOT}/config.h" | awk '{print $3}' | tr -d '"'
}
pikiss=$(getopt 'pikiss_script')
pikissdir=$(getopt 'pikissdir')
getappssh="${MESON_INSTALL_PREFIX}/share/pikiss-gui/getapps.sh"
echo 'Creating App import script...'
#Create getapps.sh
cat << EOF > ${getappssh}
#!/bin/bash
## Apps Refresh Script for PiKISS GUI
## By Jai-JAP <jai.jap.318@gmail.com>
## getapps script autogenerated at install
# echo -e "\\x1b[1;5;93mThis script may ask you for your password. \\nPlease enter your password if asked.\\x1b[0m\\n"
# echo -en "\\x1b[1;92mPress [ENTER] to continue.\\x1b[0m" ; read -p ""
disabled_apps=\$(grep "[[:blank:]]# " ${pikiss} | awk '{print \$2}' | tr '\\n' '|' | sed 's/|$//')
declare -a categories=("Tweaks" "Games" "Emulators" "Info" "Multimedia" "Configure" "Internet" "Server" "Devs" "Others")
for category in "\${categories[@]}";
do
mkdir -p "${datadir}\$category"
awk -v smcat="sm\$category" '\$0~smcat{f=1; next} /done/{f=0} f' ${pikiss} |
awk '/esac/{f=0} f; /Back\) break ;;/{f=1}' | sed -r 's+\)+.sh+g' | sed -r 's|VSCode/ium|VSCode|g' |
sed -r 's|./scripts| ${pikissdir}/scripts|g' | tr -d ';' | grep -v uninstall_pikiss | grep -v -E "\$disabled_apps" |
awk -v inst="${datadir}\$category/" '{print "sudo ln -s ",\$2,inst\$1,"2>/dev/null"}' | bash
echo .
done
find ${datadir} -xtype l -delete
echo -en "\\n\\x1b[1;92mPiKISS Apps successfully synced.\\x1b[0m\\n"
exit 0
EOF
chmod a+x "${getappssh}"
echo -e 'App import script created successfully.\n'
#Create PiKISS GUI Sync Apps menuentry
echo 'Creating PiKISS GUI Sync Apps menuentry...'
cat << EOF > ${menuentrypath}pikiss-gui-sync-apps.desktop
[Desktop Entry]
Name=PiKISS GUI Sync Apps
GenericName=PiKISS App Sync
Comment=Sync Apps with PiKISS
Categories=Utility;
Exec=${getappssh}
Icon=${iconpath}
Terminal=true
Type=Application
StartupNotify=true
EOF
chmod a+x "${menuentrypath}pikiss-gui-sync-apps.desktop"
echo 'PiKISS GUI Sync Apps menuentry created successfully.'
echo -e '\x1b[1;92mFor resyncing apps with PiKISS use menu launcher \x1b[1;91m"PiKISS GUI Sync Apps"\x1b[0m\n'
#Creating App description fetch script
getdescsh="${MESON_INSTALL_PREFIX}/share/pikiss-gui/getdesc.sh"
echo 'Creating App description fetch script...'
#Create getdesc.sh
cat << EOF > ${getdescsh}
#!/bin/bash
## Apps description fetch Script for PiKISS GUI
## By Jai-JAP <jai.jap.318@gmail.com>
## getdesc script autogenerated at install
grep "\${1} " ~/piKiss/piKiss.sh | awk '{for (i=2; i<NF; i++) printf \$i " "; print \$NF}' | head -n1 | tr -d '"' | tr -d "\\n"
EOF
chmod a+x "${getdescsh}"
echo -e 'App description fetch script created successfully.\n'
#Creating Uninstall script
uninstallsh=${MESON_SOURCE_ROOT}/uninstall.sh
echo 'Creating uninstall script'
cat << EOF > ${uninstallsh}
#!/bin/bash
## PiKISS GUI Uninstall script autogenerated at install
{
sudo ninja -C build uninstall | grep -v "Remember that files created by custom scripts have not been removed."
echo -e "Attempting removal of PiKISS GUI data files..."
sudo rm ${menuentrypath}pikiss-gui*.desktop
sudo rm -rf ${datadir}
echo PiKISS GUI data files successfully removed
sudo rm -f ${uninstallsh}
}
EOF
chmod a+x $uninstallsh
echo -e 'Uninstall script created successfully.\n'
#Syncing Apps
echo -e 'Syncing Apps with PiKISS...\n\n'
if [[ $(id -u) == '0' ]]; then
su $SUDO_USER ${getappssh}
else
${getappssh}
fi