-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprc_njs_2023_update_install_ui.sh
145 lines (123 loc) · 4.08 KB
/
prc_njs_2023_update_install_ui.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
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
#!/bin/bash
# Check for color support
if [ -t 1 ]; then
ncolors=$( tput colors )
if [ -n "${ncolors}" -a "${ncolors}" -ge 8 ]; then
if normal="$( tput sgr0 )"; then
# Use terminfo names
red="$( tput setaf 1 )"
green="$( tput setaf 2)"
yellow="$( tput setaf 3)"
blue="$( tput setaf 4)"
magenta="$( tput setaf 5)"
cyan="$( tput setaf 6)"
white="$( tput setaf 7)"
else
# Use termcap names for FreeBSD compat
normal="$( tput me )"
red="$( tput AF 1 )"
green="$( tput AF 2)"
yellow="$( tput AF 3)"
blue="$( tput AF 4)"
magenta="$( tput AF 5)"
cyan="$( tput AF 6)"
white="$( tput AF 7)"
fi
fi
fi
# For security reasons user shuld not run as root
echo ""
echo "Checking to ensure ${red}root${normal} user is not being utilized"
echo "and script was not called with ${red}sudo${normal} priveliges..."
sleep 2
echo ""
if [ "$_user" = "root" ]; then
echo "${red}Root user login detected...${normal}"
sleep 1
echo "${red}Qoral-UI update/install script for Linux will now exit, goodbye!${normal}"
sleep 2
echo ""
# Exit under general error
exit 1
elif [ "$SUDO_USER" != "" ]; then
echo "${red}Script was called via sudo...${normal}"
sleep 1
echo "Qoral-UI update/install script for Linux will now exit, goodbye!"
sleep 2
echo ""
# Exit under general error
exit 1
elif [ "$_user" != "root" ] && [ "$SUDO_USER" = "" ]; then
# Small intro and declaration of versioning
echo "==========================================================================="
echo " Qortal-UI update/install script for Linux by ${cyan}HFactor${normal} (V3.0) "
echo "==========================================================================="
echo ""
sleep 2
echo "This script will build the Qortal-UI from soruce and will require ${red}sudo${normal}"
echo "privileges for one or more calls before script completion..."
sleep 3
echo "Please enter the appropriate password when asked to ${red}avoid${normal} permissions errors!"
sleep 4
echo ""
# Disable mouse cursor
tput civis
echo "Updating APT repository..."
sudo apt update
echo ""
sleep 2
echo "${green}Installing${normal} curl if not already installed..."
sudo apt install curl -y
echo ""
sleep 2
echo "${red}Stopping${normal} node.js if running...ID10T preventive..."
sudo killall -9 node*
echo ""
sleep 2
echo "${green}Installing${normal} NPM and nodeJS from NodeSource repository..."
sleep 1
echo "This will add a new repository in sources.list.d and"
sleep 1
echo "pull updates when apt update/upgrade are utilized."
sleep 3
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash - &&\
sudo apt install -y nodejs
echo ""
echo "${red}Disabling${normal} npm ""funding"" message/s..."
npm config set fund false
echo ""
sleep 2
echo "${red}Removing${normal} old Qortal-UI files if any..."
rm -rf qortal-ui
echo ""
sleep 2
echo "${green}Cloning${normal} git repositories for Qortal-UI"
sleep 1
git clone https://github.com/qortal/qortal-ui.git
echo ""
cd qortal-ui
# Install dependencies and call "install" from package.json "scripts" field as currently logged in user (non sudo)
echo "${green}Starting${normal} build process for Qortal-UI via npm which may take a while..."
sleep 1
npm install
echo ""
# Run "build" field from the package.json "scripts" field as currently logged in user (non sudo)
echo "${green}Starting${normal} build process for Qortal-UI server which may take a while..."
sleep 1
npm run build
echo ""
echo "${green}BUILD COMPLETE! You can now make use of the new UI!${normal}"
echo ""
sleep 2
# Re-enable mouse cursor
tput cnorm
# Read user typed key into "input" and return after reading 1 character (-n 1) without echoing to the term (-s)
echo "Press ${cyan}q${normal} to exit!"
while read -s -n 1 input; do
case "${input}" in
(q) break ;;
(*) echo "${red}Invalid key pressed!${normal}" ;;
esac
done
fi
exit 0