Skip to content

Commit b4db350

Browse files
committed
added Linux_Install.sh and desktop.template
1 parent c024184 commit b4db350

File tree

2 files changed

+250
-0
lines changed

2 files changed

+250
-0
lines changed

Diff for: Linux_Install.sh

+238
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
#!/bin/sh
2+
3+
############################################################################
4+
## Linux install script for Arduino IDE 2.0 - contributed by Art Sayler ##
5+
## https://github.com/arduinoshop ##
6+
##
7+
##
8+
############################################################################
9+
10+
echo "\nLinux install script for the Arduino IDE 2.0 ${SCRIPT_PATH}\n"
11+
12+
MODE=U
13+
YN=n
14+
RESOURCE_NAME=arduino-arduinoide2
15+
RED='\033[0;31m'
16+
NOCOLOR='\033[0m'
17+
18+
if [ -z $1 ]
19+
then
20+
echo no option selected - defaulting to single user instalation
21+
echo "usage: ./Linux_Install.sh [local] | [ulocal]"
22+
echo " local - installs IDE for user $USER only ( default if no option given )"
23+
echo " ulocal - uninstall IDE from user $USER"
24+
echo "usage: sudo ./Linux_Install.sh [system] | [usystem]"
25+
echo " system - install IDE systemwide for all users"
26+
echo " usystem - uninstall IDE systemwide from all users\n"
27+
echo "Both local and system installations may be used on the same computer"
28+
echo "for example - a stable release installed systemwide and a nightly for a development user\n"
29+
30+
MSG="Install IDE 2.0 for user $USER only?"
31+
32+
elif [ $1 = local ]
33+
then
34+
MSG="Install IDE 2.0 for user $USER only?"
35+
elif [ $1 = ulocal ]
36+
then
37+
MSG="UnInstall IDE 2.0 from user $USER?"
38+
MODE=u
39+
elif [ $1 = usystem ]
40+
then
41+
MSG="UnInstall IDE 2.0 system wide (all users will be affected)?"
42+
MODE=s
43+
elif [ $1 = system ]
44+
then
45+
MSG="Install IDE 2.0 system wide (all users will have access)?"
46+
MODE=S
47+
fi
48+
49+
# Get absolute path from which this script file was executed
50+
# (Could be changed to "pwd -P" to resolve symlinks to their target)
51+
SCRIPT_PATH=$( pwd -P )
52+
LIB_PATH=$SCRIPT_PATH
53+
EXE_PATH=$SCRIPT_PATH
54+
# echo S_PATH = $SCRIPT_PATH
55+
56+
# Install by simply copying desktop file (fallback)
57+
simple_install_f() {
58+
echo
59+
# Using Simple - MODE = $MODE
60+
###### Remove local user installation
61+
62+
if [ $MODE = u ]
63+
then
64+
echo Uninstalling IDE 2.0 from user $USER
65+
echo "Deleting ${HOME}/.local/share/applications/${RESOURCE_NAME}l.desktop"
66+
rm ${HOME}/.local/share/applications/${RESOURCE_NAME}l.desktop
67+
68+
echo "Deleting ${HOME}/.local/lib/${RESOURCE_NAME}"
69+
rm -rf ${HOME}/.local/lib/${RESOURCE_NAME}
70+
71+
echo "Deleting ${HOME}/.local/bin/${RESOURCE_NAME}"
72+
rm ${HOME}/.local/bin/${RESOURCE_NAME}
73+
74+
echo "Installation directory and it's contents including this script can be removed"
75+
read -p "Delete directory ${SCRIPT_PATH}? (YES for the affirmative)" YN
76+
if [ -z $YN ]
77+
then
78+
echo exiting; exit
79+
elif [ $YN = YES ]
80+
then
81+
echo "Removing Directory ${SCRIPT_PATH}"
82+
fi
83+
fi
84+
85+
###### Perform local user only installation
86+
if [ $MODE = U ]
87+
then
88+
echo "For a more professional installation... and to remove clutter"
89+
echo "in ${SCRIPT_PATH}\nyou have the option to move these files."
90+
read -p "Move downloaded files to ~/.local/bin and lib ? (Y/N) " YN
91+
if [ -z $YN ]
92+
then
93+
YN=n; echo "Installion files will not be copied."
94+
fi
95+
96+
LIB_PATH=${HOME}/.local/lib/${RESOURCE_NAME}
97+
EXE_PATH=${HOME}/.local/bin
98+
99+
if [ $YN = Y ] || [ $YN = y ]
100+
then
101+
mkdir -p $LIB_PATH
102+
echo -n "Copying files... "
103+
cp -rf * ${HOME}/.local/lib/${RESOURCE_NAME}
104+
echo "Files copied...\n"
105+
fi
106+
107+
mkdir -p "${HOME}/.local/bin"
108+
rm -f ${HOME}/.local/bin/${RESOURCE_NAME}
109+
ln -s ${HOME}/.local/lib/${RESOURCE_NAME}/arduino-ide ${HOME}/.local/bin/${RESOURCE_NAME}
110+
111+
# Create a temp dir accessible by all users
112+
TMP_DIR=`mktemp --directory`
113+
114+
# Create *.desktop file using the existing template file
115+
sed -e "s,<BINARY_LOCATION>,${EXE_PATH}/${RESOURCE_NAME},g" \
116+
-e "s,<id>,local,g" \
117+
-e "s,<ICON_NAME>,${LIB_PATH}/arduino2.png,g" "${SCRIPT_PATH}/desktop.template" > "${TMP_DIR}/${RESOURCE_NAME}l.desktop"
118+
119+
mkdir -p "${HOME}/.local/share/applications"
120+
cp "${TMP_DIR}/${RESOURCE_NAME}l.desktop" "${HOME}/.local/share/applications/"
121+
echo "Installing Launcher and Icon\n"
122+
123+
echo "Launcher and Icon Installed\n"
124+
echo "Go to \"Show Application\" ( button in lower left / \"Windows Key\")"
125+
echo "Search for \"Arduino\" - you will see an Icon labeled \"2.0 system\""
126+
echo "click on this icon to run the IDE or right-click to add it to the Dock\n"
127+
128+
# mkdir -p "${HOME}/.local/share/metainfo"
129+
# cp "${SCRIPT_PATH}/lib/appdata.xml" "${HOME}/.local/share/metainfo/${RESOURCE_NAME}.appdata.xml"
130+
131+
# Clean up temp dir
132+
rm "${TMP_DIR}/${RESOURCE_NAME}l.desktop"
133+
rmdir "${TMP_DIR}"
134+
fi
135+
136+
######## System Wide Install / UnInstall
137+
if [ $MODE = s ] || [ $MODE = S ]
138+
then
139+
if [ $USER != root ]
140+
then
141+
echo "$RED You must be SuperUser to make SystemWide changes$NOCOLOR\007"
142+
echo "Use sudo ./Linux_Install.sh [option]\n"
143+
exit
144+
fi
145+
fi
146+
147+
######## System Wide UnInstall
148+
149+
if [ $MODE = s ]
150+
then
151+
echo Uninstalling IDE 2.0 systemwide
152+
153+
if [ -f /usr/local/share/applications/${RESOURCE_NAME}.desktop ]
154+
then
155+
echo "Deleting /usr/local/share/applications/${RESOURCE_NAME}.desktop"
156+
rm /usr/local/share/applications/${RESOURCE_NAME}.desktop
157+
fi
158+
159+
if [ -f /usr/local/bin/${RESOURCE_NAME} ]
160+
then
161+
echo "Deleting /usr/local/bin/${RESOURCE_NAME}"
162+
rm /usr/local/bin/${RESOURCE_NAME}
163+
fi
164+
165+
if [ -d /usr/local/lib/${RESOURCE_NAME} ]
166+
then
167+
echo "Deleting Directory /usr/local/lib/${RESOURCE_NAME}"
168+
rm -rf /usr/local/lib/${RESOURCE_NAME}
169+
else
170+
echo "/usr/local/lib/${RESOURCE_NAME} does not exist"
171+
fi
172+
173+
echo "Installation directory and it's contents including this script can be removed"
174+
read -p "Delete directory ${SCRIPT_PATH} (YES)? " YN
175+
if [ -z $YN ]
176+
then
177+
echo "Directory ${SCRIPT_PATH} will not be removed"
178+
elif [ $YN != YES ]
179+
then
180+
echo "Directory ${SCRIPT_PATH} will not be removed"
181+
else
182+
echo "Removing Directory ${SCRIPT_PATH}"
183+
fi
184+
fi
185+
186+
###### Perform SystemWide installation
187+
if [ $MODE = S ]
188+
then
189+
echo -n "Copying downloaded files to /usr/local/lib... "
190+
LIB_PATH=/usr/local/lib/${RESOURCE_NAME}
191+
EXE_PATH=/usr/local/bin
192+
mkdir -p $LIB_PATH
193+
cp -rf * $LIB_PATH
194+
rm -f $EXE_PATH/${RESOURCE_NAME}
195+
ln -s $LIB_PATH/arduino-ide $EXE_PATH/${RESOURCE_NAME}
196+
echo "Files copied...\n"
197+
198+
# Create a temp dir accessible by all users
199+
TMP_DIR=`mktemp --directory`
200+
201+
# Create *.desktop file using the existing template file
202+
sed -e "s,<BINARY_LOCATION>,${EXE_PATH}/${RESOURCE_NAME},g" \
203+
-e "s,<id>,system,g" \
204+
-e "s,<ICON_NAME>,${LIB_PATH}/arduino2.png,g" "${SCRIPT_PATH}/desktop.template" > "${TMP_DIR}/${RESOURCE_NAME}.desktop"
205+
206+
mkdir -p "${HOME}/.local/share/applications"
207+
cp "${TMP_DIR}/${RESOURCE_NAME}.desktop" "/usr/local/share/applications/"
208+
echo "Launcher and Icon Installed\n"
209+
echo "Go to \"Show Application\" ( button in lower left / \"Windows Key\")"
210+
echo "Search for \"Arduino\" - you will see an Icon labeled \"2.0 system\""
211+
echo "click on this icon to run the IDE or right-click to add it to the Dock\n"
212+
213+
# mkdir -p "${HOME}/.local/share/metainfo"
214+
# cp "${SCRIPT_PATH}/lib/appdata.xml" "${HOME}/.local/share/metainfo/${RESOURCE_NAME}.appdata.xml"
215+
216+
# Clean up temp dir
217+
rm "${TMP_DIR}/${RESOURCE_NAME}.desktop"
218+
rmdir "${TMP_DIR}"
219+
fi
220+
}
221+
222+
# --- main Script starts here ---
223+
224+
read -p "$MSG (Y/N) " YN
225+
226+
if [ -z $YN ]
227+
then
228+
echo OK - exiting
229+
exit
230+
elif [ $YN = n ]
231+
then
232+
echo OK - No is No... exiting
233+
exit
234+
fi
235+
236+
simple_install_f
237+
238+
exit

Diff for: desktop.template

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Desktop Entry]
2+
Type=Application
3+
Name=IDE <id>
4+
GenericName=Arduino IDE
5+
Comment=Open-source electronics prototyping platform
6+
Exec=<BINARY_LOCATION>
7+
Icon=<ICON_NAME>
8+
Terminal=false
9+
Categories=Development;IDE;Electronics;
10+
MimeType=text/x-arduino;
11+
Keywords=embedded electronics;electronics;avr;microcontroller;
12+
StartupWMClass=processing-app-Base

0 commit comments

Comments
 (0)