59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
# Helper Script for users to install and configure NodeJS+Holesail and then make a connection.
|
|
|
|
# Function to start holesail
|
|
start_holesail() {
|
|
holesail --host 0.0.0.0 --port "$port" "$connection_hash"
|
|
}
|
|
|
|
# Function to start holesail in pm2
|
|
start_holesail_pm2() {
|
|
pm2 start holesail --name holesail-mc-port-"$port" -- -p "$port" --host 0.0.0.0 "$connection_hash"
|
|
}
|
|
|
|
# 1) Ensure NodeJS is installed
|
|
if ! command -v node &> /dev/null; then
|
|
echo "NodeJS is not installed. Installing..."
|
|
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
|
|
sudo apt-get install -y nodejs
|
|
fi
|
|
|
|
# 2) Check if npm packages are installed
|
|
packages=("holesail")
|
|
install_needed=false
|
|
|
|
for package in "${packages[@]}"; do
|
|
if ! npm list -g "$package" &> /dev/null; then
|
|
install_needed=true
|
|
break
|
|
fi
|
|
done
|
|
|
|
# 3) Install required npm packages if needed
|
|
if [ "$install_needed" = true ]; then
|
|
echo "Installing npm packages..."
|
|
npm install -g holesail@2.1.0
|
|
else
|
|
echo "npm packages are already installed. Skipping..."
|
|
fi
|
|
|
|
# Check command line options
|
|
if [[ "$1" == "--pm2" ]]; then
|
|
# Ask user for connection hash
|
|
read -p "Please provide a connection hash: " connection_hash
|
|
read -p "Please provide a port: " port
|
|
|
|
# Run holesail in pm2
|
|
start_holesail_pm2
|
|
|
|
else
|
|
# Ask user for connection hash and port
|
|
read -p "Please provide a connection hash: " connection_hash
|
|
read -p "Please provide a connection port: " port
|
|
|
|
# Run holesail
|
|
start_holesail
|
|
fi
|
|
|
|
# Notify user of the selected port
|
|
echo "Holesail is running on port: $port"
|