general updates
This commit is contained in:
58
agent/pkg/install.sh
Normal file
58
agent/pkg/install.sh
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# DNSBlock Agent Installer (Binary Distribution)
|
||||
|
||||
INSTALL_DIR="/opt/dnsblock"
|
||||
SOURCE_DIR=$(pwd)
|
||||
|
||||
# Check root
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing DNSBlock Agent..."
|
||||
|
||||
# Create Directory
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
|
||||
# Copy Binary
|
||||
if [ -f "$SOURCE_DIR/dnsblock-agent" ]; then
|
||||
cp "$SOURCE_DIR/dnsblock-agent" "$INSTALL_DIR/"
|
||||
chmod +x "$INSTALL_DIR/dnsblock-agent"
|
||||
else
|
||||
echo "Error: dnsblock-agent binary not found in current directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create Config if not exists
|
||||
if [ ! -f "$INSTALL_DIR/config.json" ]; then
|
||||
echo "Creating default config..."
|
||||
if [ -f "$SOURCE_DIR/config.json.example" ]; then
|
||||
cp "$SOURCE_DIR/config.json.example" "$INSTALL_DIR/config.json"
|
||||
else
|
||||
cat <<EOF > "$INSTALL_DIR/config.json"
|
||||
{
|
||||
"serial_key": "YOUR_SERIAL_KEY_HERE",
|
||||
"api_url": "https://seu-painel.com",
|
||||
"rpz_file": "/opt/dnsblock/rpz.dnsblock.zone"
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
echo "Config file created at $INSTALL_DIR/config.json. Please edit it with your Serial Key and API URL."
|
||||
fi
|
||||
|
||||
# Setup Systemd Service
|
||||
echo "Setting up systemd service..."
|
||||
if [ -f "$SOURCE_DIR/dnsblock-agent.service" ]; then
|
||||
cp "$SOURCE_DIR/dnsblock-agent.service" /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable dnsblock-agent
|
||||
|
||||
echo "Installation Complete!"
|
||||
echo "1. Edit /opt/dnsblock/config.json"
|
||||
echo "2. Start service: systemctl start dnsblock-agent"
|
||||
else
|
||||
echo "Error: dnsblock-agent.service not found."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user