forked from Botspot/pi-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·197 lines (168 loc) · 5.37 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
#!/bin/bash
function error {
echo -e "\e[91m$1\e[39m"
exit 1
}
cd $HOME
DIRECTORY="$(readlink -f "$(dirname "$0")")"
#install yad automatically
if ! command -v yad >/dev/null;then
if [ -f /usr/bin/apt ];then
sudo apt update
sudo apt install -y yad || error "Failed to install yad."
updated=1
else
error "Failed to find any package manager to install yad."
fi
fi
#remove annoying YAD icon browser launcher
sudo rm -f /usr/share/applications/yad-icon-browser.desktop
#install git
if ! command -v git >/dev/null;then
if [ -f /usr/bin/apt ];then
#only run sudo apt update if not already run
if [ -z "$updated" ];then
sudo apt update
updated=1
fi
sudo apt install -y git || error "Failed to install git."
else
error "Failed to find any package manager to install git."
fi
fi
#install curl
if ! command -v curl >/dev/null;then
if [ -f /usr/bin/apt ];then
#only run sudo apt update if not already run
if [ -z "$updated" ];then
sudo apt update
updated=1
fi
sudo apt install -y curl || error "Failed to install curl."
else
error "Failed to find any package manager to install curl."
fi
fi
#download pi-apps if folder missing
if [ -z "$DIRECTORY" ] || [ "$DIRECTORY" == "$HOME" ] || [ "$DIRECTORY" == bash ];then
DIRECTORY="$HOME/pi-apps"
#if directory does not exist, download it
if [ ! -d "$DIRECTORY" ];then
echo "Downloading Pi-Apps..."
output="$(git clone --depth 1 https://github.com/Botspot/pi-apps "$DIRECTORY" 2>&1)"
if [ ! -d "$DIRECTORY" ];then
error "Pi-Apps download failed!\ngit clone output was: $output"
fi
fi
fi
#from this point in, DIRECTORY variable populated with valid pi-apps directory
#menu button
if [ ! -f ~/.local/share/applications/pi-apps.desktop ];then
echo "Creating menu button..."
fi
mkdir -p ~/.local/share/applications
echo "[Desktop Entry]
Name=Pi Apps
Comment=Raspberry Pi App Store for open source projects
Exec=${DIRECTORY}/gui
Icon=${DIRECTORY}/icons/logo.png
Terminal=false
Type=Application
Categories=Utility;" > ~/.local/share/applications/pi-apps.desktop
if [ ! -f ~/Desktop/pi-apps.desktop ];then
echo "Adding Desktop shortcut..."
fi
cp -f ~/.local/share/applications/pi-apps.desktop ~/Desktop/pi-apps.desktop
chmod +x ~/Desktop/pi-apps.desktop
if [ ! -f ~/.local/share/applications/pi-apps-settings.desktop ];then
echo "Creating Settings menu button..."
fi
echo "[Desktop Entry]
Name=Pi Apps Settings
Comment=Configure Pi-Apps or create an App
Exec=${DIRECTORY}/settings
Icon=${DIRECTORY}/icons/logo.png
Terminal=false
Type=Application
Categories=Settings;" > ~/.local/share/applications/pi-apps-settings.desktop
if [ ! -f ~/.config/autostart/pi-apps-updater.desktop ];then
echo "Creating autostarted updater..."
fi
mkdir -p ~/.config/autostart
echo "[Desktop Entry]
Name=Pi Apps Updater
Exec=${DIRECTORY}/updater onboot
Icon=${DIRECTORY}/icons/logo.png
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
Hidden=false
NoDisplay=false" > ~/.config/autostart/pi-apps-updater.desktop
mkdir -p "${DIRECTORY}/data" && cd "${DIRECTORY}/data" || error "Failed to make and enter ${DIRECTORY}/data directory!"
mkdir -p installed-packages preload settings status update-status categories
cd $HOME
#hide template file by default
"${DIRECTORY}/etc/categoryedit" "template" 'hidden' >/dev/null
#hide duplicates if running in twisteros
if [ -f /usr/local/bin/twistver ] && if [[ $(twistver) == "Twister OS version"* ]]; then
#twisteros full
PREIFS="$IFS"
IFS=$'\n'
apps="CommanderPi
Box86
Discord
piKiss
Retropie
Scrcpy
Steam
Windows 10 Theme
Chromium Widevine
Lightpad
Wine (x86)
Mac OS Theme"
for app in $apps ;do
"${DIRECTORY}/etc/categoryedit" "$app" 'hidden' >/dev/null
done
#unhide chromiumv78 on twisteros
"${DIRECTORY}/etc/categoryedit" 'Back to Chromium v78' >/dev/null
echo "Finished hiding apps on TwisterOS."
elif [ -f /usr/local/bin/twistver ] && if [[ $(twistver) != "Twister OS version"* ]]; then
#twisteros lite
PREIFS="$IFS"
IFS=$'\n'
apps="Chromium Widevine
Box86
Windows 10 Theme
Lightpad
Wine (x86)
Mac OS Theme"
for app in $apps ;do
"${DIRECTORY}/etc/categoryedit" "$app" 'hidden' >/dev/null
done
#unhide some apps on twisteros lite that were hidden.
#This moves these apps to the '' category, which will be reset next time pi-apps launches
"${DIRECTORY}/etc/categoryedit" CommanderPi >/dev/null
"${DIRECTORY}/etc/categoryedit" Discord >/dev/null
"${DIRECTORY}/etc/categoryedit" piKiss >/dev/null
"${DIRECTORY}/etc/categoryedit" Scrcpy >/dev/null
"${DIRECTORY}/etc/categoryedit" Steam >/dev/null
"${DIRECTORY}/etc/categoryedit" 'Chromium Widevine' >/dev/null
"${DIRECTORY}/etc/categoryedit" 'Back to Chromium v78' >/dev/null
echo "Finished hiding apps on TwisterOS."
fi
#pi-apps terminal command
if [ ! -f /usr/local/bin/pi-apps ] || ! cat /usr/local/bin/pi-apps | grep -q "${DIRECTORY}/gui";then
echo "#!/bin/bash
${DIRECTORY}/gui" | sudo tee /usr/local/bin/pi-apps >/dev/null
sudo chmod +x /usr/local/bin/pi-apps
echo "You can now launch pi-apps from a terminal, just by running 'pi-apps'"
fi
if [ "$(ls "$DIRECTORY/data/settings" 2>/dev/null | wc -l)" -le 2 ];then
echo "Generating default settings..."
fi
"${DIRECTORY}/settings" refresh
if [ ! -f "$DIRECTORY/data/preload/LIST-" ];then
echo "Preloading app list..."
fi
"${DIRECTORY}/preload" &>/dev/null
echo "Installation complete."