-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·84 lines (68 loc) · 1.82 KB
/
update.sh
File metadata and controls
executable file
·84 lines (68 loc) · 1.82 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
reset
echo "NodeJSManager"
echo "By Justman10000"
sleep 1
reset
version=$(curl -s https://nodejs.org/dist/ | grep -oP '\d+\.\d+\.\d+' | sort -rV | head -n 1)
oldVersion=$(node -v)
checkVersion=$(echo $version | grep -oP '\d\d')
usedGeneration=$(node -v | grep -oP '\d\d' | head -n 1)
if ! [ -d /usr/local/node ]; then
echo "NodeJS is not installed!"
exit 1
fi
if ! [ -d /usr/local/node/v$checkVersion* ]; then
echo "It exists no a NodeJS version of the $checkVersion. generation"
fi
if [ $usedGeneration != $checkVersion ]; then
echo "You use not the latest generation of NodeJS!"
sleep 1
echo "This Script only works with using the latest NodeJS generation"
sleep 1
echo "Used generation: $usedGeneration"
echo "Latest generation: $checkVersion"
exit 1
fi
if [[ $oldVersion != v$version ]]; then
echo "Your NodeJS is outdated!"
echo "Install the new version?"
options=(
"Yes"
"No"
)
select option in "${options[@]}"; do
case $option in
"Yes")
wget https://nodejs.org/dist/v$version/node-v$version-linux-x64.tar.xz
unxz *.xz
tar xvf *.tar
rm -r *.tar
mv node-v$version-linux-x64 /usr/local/node/v$version
ln -fs /usr/local/node/v$version/bin/* /usr/bin
corepack enable
;;
"No")
exit 0
;;
esac
break
done
echo "Uninstall the old version?"
options=(
"Yes"
"No"
)
select option in $options; do
case $option in
"Yes")
rm -r /usr/local/node/$oldVersion
;;
"No")
exit 0
;;
esac
done
else
echo "You use the newest version!"
exit
fi