1+ name : " Deploy BrightSign Python Extension"
2+ description : " Deploy latest pydev package to BrightSign player with automatic package detection and user preference memory"
3+
4+ args :
5+ - name : " player_ip"
6+ description : " IP address of BrightSign player"
7+ type : " string"
8+ - name : " password"
9+ description : " SSH password (default: password)"
10+ type : " string"
11+ - name : " destination_path"
12+ description : " Destination path on player (default: /storage/sd/)"
13+ type : " string"
14+
15+ steps :
16+ - name : " Load configuration and find latest package"
17+ run : |
18+ # Load existing configuration
19+ CONFIG_FILE=".deploy_config"
20+ SAVED_IP=""
21+ SAVED_DEST=""
22+
23+ if [ -f "$CONFIG_FILE" ]; then
24+ source "$CONFIG_FILE"
25+ echo "📁 Loaded saved configuration"
26+ fi
27+
28+ # Find latest pydev package
29+ LATEST_PYDEV=$(ls -t pydev-*.zip 2>/dev/null | head -1)
30+ if [ -z "$LATEST_PYDEV" ]; then
31+ echo "❌ No pydev-*.zip files found. Run './package' first."
32+ exit 1
33+ fi
34+
35+ PACKAGE_SIZE=$(ls -lh "$LATEST_PYDEV" | awk '{print $5}')
36+ PACKAGE_DATE=$(ls -l "$LATEST_PYDEV" | awk '{print $6, $7, $8}')
37+
38+ echo "📦 Found latest package: $LATEST_PYDEV"
39+ echo " Size: $PACKAGE_SIZE"
40+ echo " Date: $PACKAGE_DATE"
41+ echo ""
42+ save_to_var : " package_info"
43+
44+ - name : " Handle IP address argument"
45+ run : |
46+ # Determine IP address to use
47+ if [ -n "$player_ip" ]; then
48+ DEPLOY_IP="$player_ip"
49+ echo "🌐 Using provided IP: $DEPLOY_IP"
50+ elif [ -n "$SAVED_IP" ]; then
51+ echo "🌐 Found saved IP: $SAVED_IP"
52+ read -p "Use saved IP $SAVED_IP? (Y/n): " -n 1 -r
53+ echo
54+ if [[ $REPLY =~ ^[Nn]$ ]]; then
55+ read -p "Enter BrightSign player IP: " DEPLOY_IP
56+ else
57+ DEPLOY_IP="$SAVED_IP"
58+ fi
59+ else
60+ read -p "Enter BrightSign player IP: " DEPLOY_IP
61+ fi
62+
63+ # Validate IP format
64+ if ! echo "$DEPLOY_IP" | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' > /dev/null; then
65+ echo "❌ Invalid IP format: $DEPLOY_IP"
66+ exit 1
67+ fi
68+
69+ echo "✅ Using IP: $DEPLOY_IP"
70+ save_to_var : " ip_handling"
71+
72+ - name : " Handle destination path argument"
73+ run : |
74+ # Determine destination path to use
75+ if [ -n "$destination_path" ]; then
76+ DEPLOY_DEST="$destination_path"
77+ echo "📂 Using provided destination: $DEPLOY_DEST"
78+ elif [ -n "$SAVED_DEST" ]; then
79+ echo "📂 Found saved destination: $SAVED_DEST"
80+ read -p "Use saved destination $SAVED_DEST? (Y/n): " -n 1 -r
81+ echo
82+ if [[ $REPLY =~ ^[Nn]$ ]]; then
83+ read -p "Enter destination path (/storage/sd/): " DEPLOY_DEST
84+ DEPLOY_DEST=${DEPLOY_DEST:-/storage/sd/}
85+ else
86+ DEPLOY_DEST="$SAVED_DEST"
87+ fi
88+ else
89+ read -p "Enter destination path (/storage/sd/): " DEPLOY_DEST
90+ DEPLOY_DEST=${DEPLOY_DEST:-/storage/sd/}
91+ fi
92+
93+ # Ensure destination ends with /
94+ if [[ ! "$DEPLOY_DEST" =~ /$ ]]; then
95+ DEPLOY_DEST="$DEPLOY_DEST/"
96+ fi
97+
98+ echo "✅ Using destination: $DEPLOY_DEST"
99+ save_to_var : " dest_handling"
100+
101+ - name : " Handle password"
102+ run : |
103+ # Set password with default
104+ DEPLOY_PASSWORD="${password:-password}"
105+ echo "🔐 Using password: [hidden]"
106+ save_to_var : " password_handling"
107+
108+ - name : " Check prerequisites and connectivity"
109+ run : |
110+ echo "🔍 Checking prerequisites..."
111+
112+ # Check for sshpass
113+ if ! command -v sshpass &> /dev/null; then
114+ echo "❌ sshpass is required but not installed."
115+ echo " Install with: sudo apt-get install sshpass"
116+ exit 1
117+ fi
118+
119+ # Test connectivity
120+ echo "🏓 Testing connectivity to $DEPLOY_IP..."
121+ if ! ping -c 1 -W 3 "$DEPLOY_IP" &> /dev/null; then
122+ echo "⚠️ Player at $DEPLOY_IP is not responding to ping"
123+ read -p "Continue anyway? (y/N): " -n 1 -r
124+ echo
125+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
126+ echo "❌ Deployment cancelled"
127+ exit 1
128+ fi
129+ else
130+ echo "✅ Player is reachable"
131+ fi
132+
133+ - name : " Deploy package to player"
134+ run : |
135+ echo ""
136+ echo "🚀 Deploying $LATEST_PYDEV to brightsign@$DEPLOY_IP:$DEPLOY_DEST"
137+ echo " Package size: $PACKAGE_SIZE"
138+ echo ""
139+
140+ # Perform the deployment
141+ echo "📤 Starting file transfer..."
142+ if sshpass -p "$DEPLOY_PASSWORD" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
143+ "$LATEST_PYDEV" brightsign@"$DEPLOY_IP":"$DEPLOY_DEST" 2>/dev/null; then
144+ echo "✅ Package transfer completed successfully!"
145+ else
146+ echo "❌ File transfer failed!"
147+ echo " Check that:"
148+ echo " - Player IP is correct: $DEPLOY_IP"
149+ echo " - Password is correct"
150+ echo " - Player is powered on and connected"
151+ echo " - Destination path exists: $DEPLOY_DEST"
152+ exit 1
153+ fi
154+
155+ - name : " Deploy user-init examples"
156+ run : |
157+ echo ""
158+ echo "📁 Deploying user-init/examples directory..."
159+
160+ # Check if examples directory exists
161+ if [ ! -d "user-init/examples" ]; then
162+ echo "⚠️ user-init/examples directory not found, skipping..."
163+ else
164+ # Count files to be copied
165+ FILE_COUNT=$(find user-init/examples -type f | wc -l)
166+ echo " Found $FILE_COUNT files to copy"
167+
168+ # Create remote directory structure
169+ # First create a marker file to ensure directory creation
170+ echo "# Directory marker" > /tmp/.deploy_marker
171+ REMOTE_INIT_DIR="${DEPLOY_DEST}user-init"
172+
173+ # Try to create the directory by copying marker file
174+ sshpass -p "$DEPLOY_PASSWORD" scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
175+ /tmp/.deploy_marker brightsign@"$DEPLOY_IP":"$REMOTE_INIT_DIR/.marker" 2>/dev/null || {
176+ echo " Creating user-init directory..."
177+ }
178+ rm -f /tmp/.deploy_marker
179+
180+ # Copy all files from examples directory
181+ echo "📤 Copying example files..."
182+ if sshpass -p "$DEPLOY_PASSWORD" scp -r -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
183+ user-init/examples brightsign@"$DEPLOY_IP":"$REMOTE_INIT_DIR/" 2>/dev/null; then
184+ echo "✅ Example files deployed successfully!"
185+ echo " Location: $REMOTE_INIT_DIR/examples/"
186+
187+ # List some of the key files copied
188+ echo ""
189+ echo " Key files deployed:"
190+ echo " - test_cv2_dnn.py (OpenCV DNN test script)"
191+ echo " - debug_cv2_dnn.py (DNN debugging script)"
192+ if [ -f "user-init/examples/requirements.txt" ]; then
193+ echo " - requirements.txt (Python dependencies)"
194+ fi
195+ if [ -f "user-init/examples/01_validate_cv.sh" ]; then
196+ echo " - 01_validate_cv.sh (CV validation script)"
197+ fi
198+ else
199+ echo "⚠️ Failed to copy example files"
200+ echo " This is non-fatal - package was deployed successfully"
201+ echo " You may need to manually copy the examples"
202+ fi
203+ fi
204+
205+ - name : " Save configuration for future use"
206+ run : |
207+ # Save IP and destination for next time
208+ echo "💾 Saving configuration for future use..."
209+ cat > "$CONFIG_FILE" << EOF
210+ # BrightSign Deploy Configuration
211+ # Automatically generated - safe to edit
212+ SAVED_IP="$DEPLOY_IP"
213+ SAVED_DEST="$DEPLOY_DEST"
214+ EOF
215+ echo "✅ Configuration saved to $CONFIG_FILE"
216+
217+ - name : " Show deployment summary and next steps"
218+ run : |
219+ echo ""
220+ echo "🎉 Deployment completed successfully!"
221+ echo ""
222+ echo "=== Deployment Summary ==="
223+ echo "Package: $LATEST_PYDEV ($PACKAGE_SIZE)"
224+ echo "Player: brightsign@$DEPLOY_IP"
225+ echo "Location: $DEPLOY_DEST$(basename $LATEST_PYDEV)"
226+ if [ -d "user-init/examples" ]; then
227+ echo "Examples: ${DEPLOY_DEST}user-init/examples/"
228+ fi
229+ echo ""
230+ echo "=== Next Steps ==="
231+ echo ""
232+ echo "1. SSH to the player:"
233+ echo " ssh brightsign@$DEPLOY_IP"
234+ echo ""
235+ echo "2. Extract the development package:"
236+ echo " cd /usr/local"
237+ echo " unzip $DEPLOY_DEST$(basename $LATEST_PYDEV)"
238+ echo ""
239+ echo "3. Activate the Python environment:"
240+ echo " source sh/pydev-env"
241+ echo " # OR: source sh/setup_python_env"
242+ echo ""
243+ echo "4. Test OpenCV DNN functionality:"
244+ echo " python3 ${DEPLOY_DEST}user-init/examples/test_cv2_dnn.py"
245+ echo " python3 ${DEPLOY_DEST}user-init/examples/debug_cv2_dnn.py"
246+ echo ""
247+ echo "5. Run other example scripts:"
248+ echo " cd ${DEPLOY_DEST}user-init/examples"
249+ echo " ls -la # See all available examples"
250+ echo ""
251+ echo "💡 Note: Development installation is volatile (lost on reboot)"
252+ echo " For permanent installation, use ext_pydev-*.zip instead"
253+ echo ""
0 commit comments