Generally functional. Added upload script
This commit is contained in:
70
deploy_lt.sh
Executable file
70
deploy_lt.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# Deployment script for Superball Thrower to lt server
|
||||
# This script builds the binary locally and deploys it to the server
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Superball Thrower Deployment Script ==="
|
||||
|
||||
# Configuration
|
||||
SERVER="ubuntu@laantungir.com"
|
||||
DEPLOY_DIR="/usr/local/bin/super_ball_thrower"
|
||||
BINARY_NAME="superball_thrower"
|
||||
SERVICE_NAME="superball-thrower"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Step 1: Clean previous build
|
||||
echo -e "${YELLOW}[1/6] Cleaning previous build...${NC}"
|
||||
make clean || true
|
||||
|
||||
# Step 2: Build the project
|
||||
echo -e "${YELLOW}[2/6] Building superball_thrower...${NC}"
|
||||
make
|
||||
|
||||
# Check if build was successful
|
||||
if [ ! -f "$BINARY_NAME" ]; then
|
||||
echo -e "${RED}Error: Build failed - binary not found${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Build successful!${NC}"
|
||||
|
||||
# Step 3: Stop the service on the server
|
||||
echo -e "${YELLOW}[3/6] Stopping service on server...${NC}"
|
||||
ssh $SERVER "sudo systemctl stop $SERVICE_NAME" || echo "Service not running or doesn't exist yet"
|
||||
|
||||
# Step 4: Deploy binary to server
|
||||
echo -e "${YELLOW}[4/6] Deploying binary to server...${NC}"
|
||||
scp $BINARY_NAME $SERVER:~/$BINARY_NAME
|
||||
|
||||
# Step 5: Move binary to final location with proper permissions
|
||||
echo -e "${YELLOW}[5/6] Installing binary...${NC}"
|
||||
ssh $SERVER "sudo mv ~/$BINARY_NAME $DEPLOY_DIR/$BINARY_NAME && \
|
||||
sudo chown superball-thrower:superball-thrower $DEPLOY_DIR/$BINARY_NAME && \
|
||||
sudo chmod 755 $DEPLOY_DIR/$BINARY_NAME"
|
||||
|
||||
# Step 6: Restart the service
|
||||
echo -e "${YELLOW}[6/6] Starting service...${NC}"
|
||||
ssh $SERVER "sudo systemctl start $SERVICE_NAME"
|
||||
|
||||
# Wait a moment for service to start
|
||||
sleep 2
|
||||
|
||||
# Check service status
|
||||
echo ""
|
||||
echo -e "${YELLOW}Service Status:${NC}"
|
||||
ssh $SERVER "sudo systemctl status $SERVICE_NAME --no-pager" || true
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}=== Deployment Complete ===${NC}"
|
||||
echo ""
|
||||
echo "Useful commands:"
|
||||
echo " View logs: ssh $SERVER 'sudo journalctl -u $SERVICE_NAME -f'"
|
||||
echo " Check status: ssh $SERVER 'sudo systemctl status $SERVICE_NAME'"
|
||||
echo " Restart: ssh $SERVER 'sudo systemctl restart $SERVICE_NAME'"
|
||||
echo " Stop: ssh $SERVER 'sudo systemctl stop $SERVICE_NAME'"
|
||||
Reference in New Issue
Block a user