This repository was archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-insiders.sh
More file actions
executable file
·156 lines (156 loc) · 5.67 KB
/
Copy pathupdate-insiders.sh
File metadata and controls
executable file
·156 lines (156 loc) · 5.67 KB
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
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
LBLUE='\033[1;34m'
YELLOW='\033[1;33m'
PURPLE='\033[1;35m'
NC='\033[0m'
quiet='false'
printf "${PURPLE} _ _ _ _ _ \n _ _ _ __ __| |__ _| |_ ___ ___(_)_ _ __(_)__| |___ _ _ ___\n | || | '_ \/ _\` / _\` | _/ -_)___| | ' \(_-< / _\` / -_) '_(_-<\n \_,_| .__/\__,_\__,_|\__\___| |_|_||_/__/_\__,_\___|_| /__/\n |_| \n${NC}"
printf "${LBLUE}(C) reoccurcat 2021-present using the GNU GPL v3 License${NC}\n\n"
print_usage() {
echo -e "Command help\n-q Runs non-verbosely"
exit 1
}
while getopts 'hq' flag; do
case "${flag}" in
q) quiet='true' ;;
h) print_usage ;;
esac
done
if [ $quiet == 'true' ]; then
sudo echo >> /dev/null
if [ $? -gt 0 ]; then
echo -e "${RED}Failed to get sudo access. Please rerun the script.${NC}"
exit
fi
pgrep -f 'code-insiders' >> /dev/null
if [ $? -eq 0 ]; then
pkill -f 'code-insiders'
if [ $? -gt 0 ]; then
sudo pkill -e -f 'code-insiders'
if [ $? -gt 0 ]; then
echo -e "${RED}Failed.${NC}"
read -n 1 -s -r -p "Press any key to continue."
exit
fi
fi
fi
if [[ -d "/usr/share/vscode-insiders" ]]; then
sudo rm -r /usr/share/vscode-insiders
fi
if [[ -d "/opt/vscode-insiders" ]]; then
sudo rm -r /opt/vscode-insiders
sudo mkdir /opt/vscode-insiders
else
sudo mkdir /opt/vscode-insiders
fi
wget -nv 'https://code.visualstudio.com/sha/download?build=insider&os=linux-x64' -O /tmp/vscode-insiders.tar.gz
sudo tar xf /tmp/vscode-insiders.tar.gz -C /opt/vscode-insiders/ --strip-components 1
if [[ -f "/usr/share/applications/code-insiders.desktop" ]]; then
sudo rm -r /usr/share/applications/code-insiders.desktop
fi
sudo cp ./code-insiders.desktop /usr/share/applications/code-insiders.desktop
grep -Fxq "alias code-insiders=/opt/vscode-insiders/bin/code-insiders" ~/.bashrc
if [ $? -eq 1 ]; then
source ~/.bashrc
fi
printf "${GREEN}Completed.${NC}\n"
read -n 1 -s -r -p "Press any key to continue."
exit
else
printf "Getting ${YELLOW}SUDO${NC} access...\n"
sudo printf "${GREEN}Achieved!${NC}\n"
if [ $? -gt 0 ]; then
echo -e "${RED}Failed. Please rerun the script.${NC}"
exit
fi
echo "$ pgrep -f 'code-insiders' >> /dev/null"
pgrep -f 'code-insiders' >> /dev/null
if [ $? -eq 0 ]; then
echo -e "${YELLOW}Insider instances are running.${NC}"
while true
do
read -r -p "Do you want to kill them? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "$ pkill -e -f 'code-insiders'"
pkill -e -f 'code-insiders'
if [ $? -gt 0 ]; then
echo -e "${RED}Failed to kill processes. ATTEMTING AS ROOT.${NC}"
echo "# pkill -e -f 'code-insiders'"
sudo pkill -e -f 'code-insiders'
if [ $? -gt 0 ]; then
echo -e "${RED}Failed.${NC}"
exit
fi
fi
break
;;
[nN][oO]|[nN])
echo -e "${RED}CONTINUE AT YOUR OWN RISK. FILE CORRUPTION IS POSSIBLE.${NC}"
while true
do
read -r -p "Are you sure you want to continue? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo -e "${RED}YOU HAVE BEEN WARNED.${NC}"
break
;;
[nN][oO]|[nN])
echo -e "${BLUE}Exiting...${NC}"
exit
;;
*)
echo -e "${YELLOW}Invalid input.${NC}"
;;
esac
done
break
;;
*)
echo -e "${YELLOW}Invalid input.${NC}"
;;
esac
done
else
echo -e "${BLUE}No insider instances running, continuing...${NC}"
fi
if [[ -d "/usr/share/vscode-insiders" ]]; then
echo "# sudo rm -r /usr/share/vscode-insiders"
sudo rm -r /usr/share/vscode-insiders
fi
if [[ -d "/opt/vscode-insiders" ]]; then
echo "# sudo rm -r /opt/vscode-insiders"
sudo rm -r /opt/vscode-insiders
echo "# mkdir /opt/vscode-insiders"
sudo mkdir /opt/vscode-insiders
else
echo "# mkdir /opt/vscode-insiders"
sudo mkdir /opt/vscode-insiders
fi
echo "$ wget -nv 'https://code.visualstudio.com/sha/download?build=insider&os=linux-x64' -O /tmp/vscode-insiders.tar.gz"
wget -nv 'https://code.visualstudio.com/sha/download?build=insider&os=linux-x64' -O /tmp/vscode-insiders.tar.gz
echo "# tar xf /tmp/vscode-insiders.tar.gz -C /opt/vscode-insiders/ --strip-components 1"
sudo tar xf /tmp/vscode-insiders.tar.gz -C /opt/vscode-insiders/ --strip-components 1
if [[ -f "/usr/share/applications/code-insiders.desktop" ]]; then
echo "# rm -r /usr/share/applications/code-insiders.desktop"
sudo rm -r /usr/share/applications/code-insiders.desktop
fi
echo "# cp ./code-insiders.desktop /usr/share/applications/code-insiders.desktop"
sudo cp ./code-insiders.desktop /usr/share/applications/code-insiders.desktop
echo '$ grep -Fxq "alias code-insiders=/opt/vscode-insiders/bin/code-insiders" ~/.bashrc'
grep -Fxq "alias code-insiders=/opt/vscode-insiders/bin/code-insiders" ~/.bashrc
if [ $? -eq 1 ]; then
echo -e "${BLUE}Alias not created, creating now...${NC}"
echo "$ echo 'alias code-insiders=/opt/vscode-insiders/bin/code-insiders' >> ~/.bashrc"
echo 'alias code-insiders=/opt/vscode-insiders/bin/code-insiders' >> ~/.bashrc
echo '$ source ~/.bashrc'
source ~/.bashrc
else
echo -e "${BLUE}Alias already found, skipping...${NC}"
fi
printf "${GREEN}All done! Check your application menu! You can also run 'code-insiders' to start it.${NC}\n"
exit
fi