-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush-development.sh
More file actions
executable file
·111 lines (95 loc) · 3.66 KB
/
push-development.sh
File metadata and controls
executable file
·111 lines (95 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Vacasa Home Assistant Integration Deployment Script
#
# Setup Instructions:
# 1. Copy .env.example to .env: cp .env.example .env
# 2. Edit .env with your Home Assistant server details
# 3. Run this script: ./new-prod-release.sh
#
# Alternatively, set environment variables:
# export HA_SERVER_IP="192.168.1.67"
# export HA_SERVER_USER="root"
# export HA_CONFIG_DIR="/homeassistant"
# Load configuration from .env file if it exists
if [ -f .env ]; then
echo "Loading configuration from .env file..."
source .env
fi
# Configuration with environment variable fallbacks
SERVER_IP="${HA_SERVER_IP:-${SERVER_IP}}"
SERVER_USER="${HA_SERVER_USER:-${SERVER_USER}}"
HA_CONFIG_DIR="${HA_CONFIG_DIR:-/homeassistant}"
# Validate required configuration
if [ -z "$SERVER_IP" ]; then
echo "❌ Error: HA_SERVER_IP not configured"
echo "Please either:"
echo " 1. Copy .env.example to .env and edit it"
echo " 2. Set environment variable: export HA_SERVER_IP=your.server.ip"
exit 1
fi
if [ -z "$SERVER_USER" ]; then
echo "❌ Error: HA_SERVER_USER not configured"
echo "Please either:"
echo " 1. Copy .env.example to .env and edit it"
echo " 2. Set environment variable: export HA_SERVER_USER=root"
exit 1
fi
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}🏠 Deploying Vacasa integration to Home Assistant server...${NC}"
echo -e "${BLUE}Server: ${SERVER_USER}@${SERVER_IP}${NC}"
echo -e "${BLUE}Config Directory: ${HA_CONFIG_DIR}${NC}"
echo ""
# Test SSH connection first
echo "Testing SSH connection..."
if ! ssh -o ConnectTimeout=10 ${SERVER_USER}@${SERVER_IP} "echo 'SSH connection successful'" > /dev/null 2>&1; then
echo -e "${RED}❌ Failed to connect to ${SERVER_IP}${NC}"
echo "Please check:"
echo " - Server is running and accessible"
echo " - SSH credentials are correct"
echo " - Network connectivity"
echo " - Configuration in .env file"
exit 1
fi
echo -e "${GREEN}✅ SSH connection successful${NC}"
# Create the destination directory if it doesn't exist
echo "Creating destination directory..."
ssh ${SERVER_USER}@${SERVER_IP} "mkdir -p ${HA_CONFIG_DIR}/custom_components"
# Remove existing Vacasa files if they exist
echo "Removing any existing Vacasa files..."
ssh ${SERVER_USER}@${SERVER_IP} "rm -rf ${HA_CONFIG_DIR}/custom_components/vacasa"
# Copy the custom component
echo "Copying files to server..."
scp -r custom_components/vacasa ${SERVER_USER}@${SERVER_IP}:${HA_CONFIG_DIR}/custom_components/
# Check if the copy was successful
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Deployment successful!${NC}"
# Automatically restart Home Assistant to apply changes
echo ""
echo "Restarting Home Assistant to apply changes..."
ssh ${SERVER_USER}@${SERVER_IP} "ha core restart"
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Home Assistant restart initiated successfully!${NC}"
echo "Home Assistant will be available again shortly."
echo ""
echo -e "${YELLOW}💡 Tip: Use './logs.sh live' to monitor the restart process${NC}"
else
echo -e "${RED}❌ Failed to restart Home Assistant.${NC}"
echo "Please restart Home Assistant manually to apply changes."
fi
echo ""
echo -e "${GREEN}🎉 Integration deployment completed!${NC}"
echo ""
echo -e "${BLUE}Next steps:${NC}"
echo " 1. Configure the integration in Home Assistant"
echo " 2. Monitor logs: ./logs.sh recent"
echo " 3. Check for errors: ./logs.sh errors"
else
echo -e "${RED}❌ Deployment failed!${NC}"
echo "Please check the error messages above and try again."
exit 1
fi