131 lines
3.1 KiB
Bash
Executable File
131 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script to deploy the OpenWebUI bot on the server
|
|
|
|
# Set the server details
|
|
SERVER_IP="104.225.217.215"
|
|
SERVER_USER="root"
|
|
DEPLOY_DIR="/root/openwebui"
|
|
|
|
# Create a temporary directory for deployment files
|
|
TEMP_DIR=$(mktemp -d)
|
|
echo "Created temporary directory: $TEMP_DIR"
|
|
|
|
# Copy the necessary files to the temporary directory
|
|
echo "Copying files to temporary directory..."
|
|
cp -r openwebui-bot $TEMP_DIR/
|
|
cp run_openwebui_bot.py $TEMP_DIR/
|
|
|
|
# Create a .env file for the bot
|
|
echo "Creating .env file..."
|
|
cat > $TEMP_DIR/openwebui-bot/.env << EOF
|
|
WEBUI_URL=http://104.225.217.215:8080
|
|
TOKEN=GdCU4ieYDqHsLfH2
|
|
MODEL_ID=llama3.1
|
|
EOF
|
|
|
|
# Create a systemd service file for the bot
|
|
echo "Creating systemd service file..."
|
|
cat > $TEMP_DIR/openwebui-bot.service << EOF
|
|
[Unit]
|
|
Description=OpenWebUI Bot Service
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=root
|
|
WorkingDirectory=$DEPLOY_DIR
|
|
ExecStart=/usr/bin/python3 $DEPLOY_DIR/run_openwebui_bot.py
|
|
Restart=always
|
|
RestartSec=10
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
# Create a deployment script
|
|
echo "Creating deployment script..."
|
|
cat > $TEMP_DIR/deploy.sh << EOF
|
|
#!/bin/bash
|
|
|
|
# Install required packages
|
|
pip install python-socketio aiohttp python-dotenv
|
|
|
|
# Copy the bot files to the deployment directory
|
|
mkdir -p $DEPLOY_DIR
|
|
cp -r openwebui-bot $DEPLOY_DIR/
|
|
cp run_openwebui_bot.py $DEPLOY_DIR/
|
|
|
|
# Set up the systemd service
|
|
cp openwebui-bot.service /etc/systemd/system/
|
|
systemctl daemon-reload
|
|
systemctl enable openwebui-bot.service
|
|
systemctl start openwebui-bot.service
|
|
|
|
echo "Bot deployed and started!"
|
|
echo "To check the status: systemctl status openwebui-bot.service"
|
|
echo "To view logs: journalctl -u openwebui-bot.service -f"
|
|
EOF
|
|
|
|
# Make the deployment script executable
|
|
chmod +x $TEMP_DIR/deploy.sh
|
|
|
|
# Create a README file
|
|
echo "Creating README file..."
|
|
cat > $TEMP_DIR/README.md << EOF
|
|
# OpenWebUI Bot Deployment
|
|
|
|
This package contains the OpenWebUI bot for channels integration.
|
|
|
|
## Files
|
|
|
|
- \`openwebui-bot/\`: The bot code
|
|
- \`run_openwebui_bot.py\`: Script to run the bot
|
|
- \`openwebui-bot.service\`: Systemd service file
|
|
- \`deploy.sh\`: Deployment script
|
|
|
|
## Deployment
|
|
|
|
1. Run the deployment script:
|
|
\`\`\`
|
|
./deploy.sh
|
|
\`\`\`
|
|
|
|
2. Check the status of the bot:
|
|
\`\`\`
|
|
systemctl status openwebui-bot.service
|
|
\`\`\`
|
|
|
|
3. View the logs:
|
|
\`\`\`
|
|
journalctl -u openwebui-bot.service -f
|
|
\`\`\`
|
|
|
|
## Configuration
|
|
|
|
The bot is configured using the \`.env\` file in the \`openwebui-bot\` directory.
|
|
EOF
|
|
|
|
# Create a tar archive of the deployment files
|
|
echo "Creating tar archive..."
|
|
cd $TEMP_DIR
|
|
tar -czf openwebui-bot-deploy.tar.gz *
|
|
cd -
|
|
|
|
# Copy the tar archive to the current directory
|
|
cp $TEMP_DIR/openwebui-bot-deploy.tar.gz .
|
|
|
|
echo "Deployment package created: openwebui-bot-deploy.tar.gz"
|
|
echo "To deploy on the server:"
|
|
echo "1. Copy the package to the server:"
|
|
echo " scp openwebui-bot-deploy.tar.gz $SERVER_USER@$SERVER_IP:~/"
|
|
echo "2. SSH into the server:"
|
|
echo " ssh $SERVER_USER@$SERVER_IP"
|
|
echo "3. Extract the package:"
|
|
echo " mkdir -p bot-deploy && tar -xzf openwebui-bot-deploy.tar.gz -C bot-deploy"
|
|
echo "4. Run the deployment script:"
|
|
echo " cd bot-deploy && ./deploy.sh"
|
|
|
|
# Clean up
|
|
rm -rf $TEMP_DIR
|