-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupdate.sh
executable file
·57 lines (48 loc) · 1.35 KB
/
update.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
#!/usr/bin/env bash
OS=$(lsb_release -si);
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
DIST="";
ARCH=$(uname -m);
if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ]; then
DIST="deb";
elif [ "$OS" = "Fedora" ] || [ "$OS" = "Red Hat" ] || [ "$OS" = "Red hat" ]; then
DIST="rpm";
else
echo "Unfortunately your operating system is not supported in distributed packages.";
exit;
fi
if [ "$ARCH" = "x86_64" ]; then
ARCH="x64";
elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64";
else
echo "Unfortunately your architecture is not supported in distributed packages.";
exit;
fi
URLBASE="https://code.visualstudio.com/sha/download?build=stable&os=linux-${DIST}-${ARCH}";
FILENAME="$DIR/latest.${DIST}";
if test -e "$FILENAME"; then
rm $FILENAME;
echo "Removed last downloaded version.";
fi
echo "Downloading latest version of vscode is starting...";
wget --show-progress -O $FILENAME $URLBASE;
RESULT="$?";
if ((RESULT != 0)); then
echo "Failed to download.";
exit 1;
fi
printf "Downloading finished.\n\n";
echo "Closing vscode...";
for pid in $(pidof code); do kill -9 $pid; done
echo "vscode instance(s) closed.";
echo "Installing latest version...";
if [ "$DIST" = "deb" ]; then
sudo dpkg -i $FILENAME;
else
sudo rpm -i $FILENAME;
fi
echo "Installation finished.";
echo "Starting new version of vscode...";
code &
exit;