Skip to content

Instantly share code, notes, and snippets.

@YukiCoco
Created May 31, 2024 09:52
Show Gist options
  • Save YukiCoco/8e4bb6a15e00ddc7387285fb8ce99af4 to your computer and use it in GitHub Desktop.
Save YukiCoco/8e4bb6a15e00ddc7387285fb8ce99af4 to your computer and use it in GitHub Desktop.
Quil 安装脚本修改版
#!/bin/bash
# Step 0: Welcome
echo "✨ Welcome! This script will prepare your server for the Quilibrium node installation. ✨"
echo ""
echo "Made with 🔥 by LaMat - https://quilibrium.one"
echo "Helped by 0xOzgur.eth - https://quilibrium.space"
echo "====================================================================================="
echo ""
echo "Processing... ⏳"
sleep 7 # Add a 7-second delay
# Exit on any error
set -e
# Step 1: Define a function for displaying exit messages
exit_message() {
echo "❌ Oops! There was an error during the script execution and the process stopped. No worries!"
echo "🔄 You can try to run the script from scratch again."
echo "🛠️ If you still receive an error, you may want to proceed manually, step by step instead of using the auto-installer."
}
# Step 2: Set a trap to call exit_message on any error
trap exit_message ERR
# Step 3: Check if directory ~/ceremonyclient exists, download from github
if [ -d ~/ceremonyclient ]; then
# Check if backup directory ~/backup/qnode_keys exists, if not create it
if [ ! -d ~/backup/qnode_keys ]; then
mkdir -p ~/backup/qnode_keys
fi
# Check if files exist, then backup
if [ -f ~/ceremonyclient/node/.config/keys.yml ]; then
cp ~/ceremonyclient/node/.config/keys.yml ~/backup/qnode_keys/
echo "✅ Backup of keys.yml created in ~/backup/qnode_keys folder"
fi
if [ -f ~/ceremonyclient/node/.config/config.yml ]; then
cp ~/ceremonyclient/node/.config/config.yml ~/backup/qnode_keys/
echo "✅ Backup of config.yml created in ~/backup/qnode_keys folder"
fi
fi
# Step 4: Download Ceremonyclient
echo "⏳Downloading Ceremonyclient"
sleep 1 # Add a 1-second delay
cd ~
if [ -d "ceremonyclient" ]; then
echo "Directory ceremonyclient already exists, skipping git clone..."
else
until git clone https://source.quilibrium.com/quilibrium/ceremonyclient.git || git clone https://git.quilibrium-mirror.ch/agostbiro/ceremonyclient.git; do
echo "Git clone failed, retrying..."
sleep 2
done
fi
cd ~/ceremonyclient/
git checkout release
# Set up environment variables (redundant but solves the command go not found error)
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
# Step 4.1: Build Ceremonyclient qClient
echo "⏳ Building qCiient..."
sleep 1 # Add a 1-second delay
cd ~/ceremonyclient/client
GOEXPERIMENT=arenas go build -o qclient main.go
# Step 5:Determine the ExecStart line based on the architecture
# Get the current user's home directory
HOME=$(eval echo ~$HOME_DIR)
# Use the home directory in the path
NODE_PATH="$HOME/ceremonyclient/node"
EXEC_START="$NODE_PATH/release_autorun.sh"
# Step 6:Create Ceremonyclient Service
echo "⏳ Creating Ceremonyclient Service"
sleep 2 # Add a 2-second delay
# Check if the file exists before attempting to remove it
if [ -f "/lib/systemd/system/ceremonyclient.service" ]; then
# If the file exists, remove it
rm /lib/systemd/system/ceremonyclient.service
echo "ceremonyclient.service file removed."
else
# If the file does not exist, inform the user
echo "ceremonyclient.service file does not exist. No action taken."
fi
sudo tee /lib/systemd/system/ceremonyclient.service > /dev/null <<EOF
[Unit]
Description=Ceremony Client Go App Service
[Service]
Type=simple
Restart=always
RestartSec=5s
WorkingDirectory=$NODE_PATH
ExecStart=$EXEC_START
[Install]
WantedBy=multi-user.target
EOF
#!/bin/bash
# Step 0: Welcome
echo "✨ Welcome! This script will change your Qnode store folder with another one for fast syncing. ✨"
echo "You must be running the node as a service, otherwise the script won't work."
echo "If you are not running as a service, follow the step-by-step process at https://iri.quest/qnode-store."
echo "Made with 🔥 by LaMat"
echo ""
echo "Processing... ⏳"
sleep 7 # Add a 7-second delay
# Function to handle errors and exit the script
handle_error() {
echo "❌ Error occurred in script at line: $1"
echo "ℹ️ Error message: $2"
exit 1
}
# Trap errors and call the handle_error function
trap 'handle_error $LINENO "$BASH_COMMAND"' ERR
# Download store from the internet
echo "🌐 Downloading store from the internet..."
wget -P ~/ceremonyclient/node/.config https://snapshots.cherryservers.com/quilibrium/store.zip || {
echo "❌ It was not possible to download the store.zip from the internet."
echo "If you have a store.zip locally, please proceed with the step-by-step method instead and use that one."
echo "More info on this page https://iri.quest/qstore-upload"
exit 1
}
echo "✅ Download completed successfully."
sleep 1
# Check if ceremonyclient service exists
if ! systemctl list-unit-files | grep -q 'ceremonyclient.service'; then
echo "❌ The 'ceremonyclient' service does not exist."
echo "Please make sure you are running the node as a service."
echo "If you are not running as a service, follow the step-by-step process at https://iri.quest/qnode-store"
exit 1
fi
# Check if zip and unzip are installed
if ! command -v zip &> /dev/null; then
echo "🚨 Zip utility is not installed. Installing..."
sudo apt-get update && sudo apt-get install -y zip || handle_error $LINENO "Failed to install zip utility."
echo "✅ Zip utility installed successfully."
fi
if ! command -v unzip &> /dev/null; then
echo "🚨 Unzip utility is not installed. Installing..."
sudo apt-get update && sudo apt-get install -y unzip || handle_error $LINENO "Failed to install unzip utility."
echo "✅ Unzip utility installed successfully."
fi
# Stop node service if it's not already stopped
if systemctl is-active --quiet ceremonyclient; then
echo "🛑 Stopping node service..."
sudo service ceremonyclient stop
echo "✅ Node service stopped successfully."
else
echo "🟢 Node service is already stopped. Moving on..."
fi
sleep 1
# Rename store to store-original if it exists
echo "🔄 Renaming store to store-original if it exists..."
if [ -d ~/ceremonyclient/node/.config/store ]; then
mv ~/ceremonyclient/node/.config/store ~/ceremonyclient/node/.config/store-original
echo "✅ Store renamed successfully."
else
echo "🟢 'store' folder not found. Skipping renaming."
fi
sleep 1
# Extract archive in store folder without showing output
echo "📦 Extracting archive in store folder..."
cd ~/ceremonyclient/node/.config
unzip store.zip -d . > /dev/null
echo "✅ Archive extracted successfully."
echo "📦 下载修复文件..."
wget -O ~/ceremonyclient/node/REPAIR "https://2040319038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwYHoFaVat0JopE1zxmDI%2Fuploads%2FJL4Ytu5OIWHbisIbZs8v%2FREPAIR?alt=media&token=d080b681-ee26-470c-baae-4723bcf018a3"
cp ~/ceremonyclient/node/REPAIR ~/ceremonyclient/node/.config/REPAIR
# Delete store.zip
echo "🗑️ Deleting store.zip"
rm ~/ceremonyclient/node/.config/store.zip
echo "✅ store.zip deleted successfully."
# Delete store-original if it exists
echo "🗑️ Deleting store-original if it exists..."
if [ -d ~/ceremonyclient/node/.config/store-original]; then
rm -rf ~/ceremonyclient/node/.config/store-original
echo "✅ 'store-original' folder deleted successfully."
else
echo "🟢 'store-original' folder not found. Skipping deletion."
fi
sleep 1
# Step 7: Start the ceremonyclient service
echo "✅ Starting Ceremonyclient Service"
sleep 2 # Add a 2-second delay
sudo systemctl daemon-reload
systemctl enable ceremonyclient
service ceremonyclient start
# Step 8: Final messages
echo "🎉 Now your node is starting!"
echo "🕒 Let it run for at least 30 minutes to generate your keys."
echo ""
echo "🔐 You can logout of your server if you want and login again later."
echo "🔒 After 30 minutes, backup your keys.yml and config.yml files."
echo "ℹ️ More info about this in the online guide: https://docs.quilibrium.one"
echo ""
echo "📜 Now I will show the node log below..."
echo "To exit the log, just type CTRL +C."
# Step 9: See the logs of the ceremonyclient service
sleep 5 # Add a 5-second delay
sudo journalctl -u ceremonyclient.service -f --no-hostname -o cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment