Skip to content

Commit 8bd7dc9

Browse files
authored
add install.sh
add install.sh for simple install routine
1 parent e31da33 commit 8bd7dc9

File tree

1 file changed

+89
-90
lines changed

1 file changed

+89
-90
lines changed

install.sh

Lines changed: 89 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,89 @@
1-
#!/usr/bin/env bash
2-
# ------------------------------------------------------------------------------
3-
# Installer for PVESciptslocal
4-
# Author: Canbiz
5-
# ------------------------------------------------------------------------------
6-
7-
set -euo pipefail
8-
9-
# Colors
10-
RD=$(echo -e "\033[01;31m")
11-
GN=$(echo -e "\033[1;92m")
12-
YW=$(echo -e "\033[33m")
13-
CL=$(echo -e "\033[m")
14-
15-
# Status functions
16-
msg_info() { echo -e "$YW$1$CL"; }
17-
msg_ok() { echo -e "✔️ $GN$1$CL"; }
18-
msg_err() { echo -e "$RD$1$CL"; }
19-
20-
# --- Check Proxmox VE environment ---
21-
if ! command -v pveversion >/dev/null 2>&1; then
22-
msg_err "This script must be executed on a Proxmox VE host."
23-
exit 1
24-
fi
25-
msg_ok "Proxmox VE detected: $(pveversion)"
26-
27-
# --- Check git ---
28-
if ! command -v git >/dev/null 2>&1; then
29-
msg_info "Git not found, installing..."
30-
apt-get update
31-
apt-get install -y git
32-
msg_ok "Git installed: $(git --version)"
33-
else
34-
msg_ok "Git already available: $(git --version)"
35-
fi
36-
37-
# --- Check Node.js ---
38-
if ! command -v node >/dev/null 2>&1; then
39-
msg_info "Node.js not found, installing Node.js 24.x..."
40-
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
41-
apt-get install -y nodejs
42-
msg_ok "Node.js installed: $(node -v)"
43-
else
44-
msg_ok "Node.js already available: $(node -v)"
45-
fi
46-
47-
# --- Ask for installation path ---
48-
read -rp "Installation directory [default: /opt/PVESciptslocal]: " INSTALL_DIR
49-
INSTALL_DIR=${INSTALL_DIR:-/opt/PVESciptslocal}
50-
51-
# --- Clone or update repository ---
52-
if [ ! -d "$INSTALL_DIR/.git" ]; then
53-
msg_info "Cloning repository into $INSTALL_DIR..."
54-
git clone https://github.com/michelroegl-brunner/PVESciptslocal.git "$INSTALL_DIR"
55-
msg_ok "Repository cloned."
56-
else
57-
msg_info "Directory already exists. Pulling latest changes..."
58-
git -C "$INSTALL_DIR" pull
59-
msg_ok "Repository updated."
60-
fi
61-
62-
cd "$INSTALL_DIR"
63-
64-
# --- Install dependencies ---
65-
msg_info "Installing dependencies..."
66-
npm install
67-
msg_ok "Dependencies installed."
68-
69-
# --- Environment file ---
70-
if [ ! -f .env ]; then
71-
msg_info "Creating environment file from example..."
72-
cp .env.example .env
73-
msg_ok ".env file created."
74-
else
75-
msg_ok ".env file already exists, keeping it."
76-
fi
77-
78-
# --- Build the application ---
79-
msg_info "Building application..."
80-
npm run build
81-
msg_ok "Build completed."
82-
83-
# --- Start the application ---
84-
read -rp "Do you want to start the application now? (y/N): " START_APP
85-
if [[ "$START_APP" =~ ^[Yy]$ ]]; then
86-
msg_info "Starting application..."
87-
npm start
88-
else
89-
msg_info "You can start the app anytime by running: cd $INSTALL_DIR && npm start"
90-
fi
1+
#!/usr/bin/env bash
2+
# ------------------------------------------------------------------------------
3+
# Installer for PVESciptslocal
4+
# ------------------------------------------------------------------------------
5+
6+
set -euo pipefail
7+
8+
# Colors
9+
RD=$(echo -e "\033[01;31m")
10+
GN=$(echo -e "\033[1;92m")
11+
YW=$(echo -e "\033[33m")
12+
CL=$(echo -e "\033[m")
13+
14+
# Status functions
15+
msg_info() { echo -e "$YW$1$CL"; }
16+
msg_ok() { echo -e "✔️ $GN$1$CL"; }
17+
msg_err() { echo -e "$RD$1$CL"; }
18+
19+
# --- Check Proxmox VE environment ---
20+
if ! command -v pveversion >/dev/null 2>&1; then
21+
msg_err "This script must be executed on a Proxmox VE host."
22+
exit 1
23+
fi
24+
msg_ok "Proxmox VE detected: $(pveversion)"
25+
26+
# --- Check git ---
27+
if ! command -v git >/dev/null 2>&1; then
28+
msg_info "Git not found, installing..."
29+
apt-get update
30+
apt-get install -y git
31+
msg_ok "Git installed: $(git --version)"
32+
else
33+
msg_ok "Git already available: $(git --version)"
34+
fi
35+
36+
# --- Check Node.js ---
37+
if ! command -v node >/dev/null 2>&1; then
38+
msg_info "Node.js not found, installing Node.js 24.x..."
39+
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
40+
apt-get install -y nodejs
41+
msg_ok "Node.js installed: $(node -v)"
42+
else
43+
msg_ok "Node.js already available: $(node -v)"
44+
fi
45+
46+
# --- Ask for installation path ---
47+
read -rp "Installation directory [default: /opt/PVESciptslocal]: " INSTALL_DIR
48+
INSTALL_DIR=${INSTALL_DIR:-/opt/PVESciptslocal}
49+
50+
# --- Clone or update repository ---
51+
if [ ! -d "$INSTALL_DIR/.git" ]; then
52+
msg_info "Cloning repository into $INSTALL_DIR..."
53+
git clone https://github.com/michelroegl-brunner/PVESciptslocal.git "$INSTALL_DIR"
54+
msg_ok "Repository cloned."
55+
else
56+
msg_info "Directory already exists. Pulling latest changes..."
57+
git -C "$INSTALL_DIR" pull
58+
msg_ok "Repository updated."
59+
fi
60+
61+
cd "$INSTALL_DIR"
62+
63+
# --- Install dependencies ---
64+
msg_info "Installing dependencies..."
65+
npm install
66+
msg_ok "Dependencies installed."
67+
68+
# --- Environment file ---
69+
if [ ! -f .env ]; then
70+
msg_info "Creating environment file from example..."
71+
cp .env.example .env
72+
msg_ok ".env file created."
73+
else
74+
msg_ok ".env file already exists, keeping it."
75+
fi
76+
77+
# --- Build the application ---
78+
msg_info "Building application..."
79+
npm run build
80+
msg_ok "Build completed."
81+
82+
# --- Start the application ---
83+
read -rp "Do you want to start the application now? (y/N): " START_APP
84+
if [[ "$START_APP" =~ ^[Yy]$ ]]; then
85+
msg_info "Starting application..."
86+
npm start
87+
else
88+
msg_info "You can start the app anytime by running: cd $INSTALL_DIR && npm start"
89+
fi

0 commit comments

Comments
 (0)