update Cerbo rollout script and guidance
This commit is contained in:
parent
2fecc345db
commit
9ba33a6cf7
Binary file not shown.
|
@ -88,6 +88,10 @@ async def import_pika(remote_host):
|
||||||
command = f"{change_dir_command} && {install_command}"
|
command = f"{change_dir_command} && {install_command}"
|
||||||
return await run_remote_command(remote_host, command)
|
return await run_remote_command(remote_host, command)
|
||||||
|
|
||||||
|
async def make_rclocal_executable(remote_host):
|
||||||
|
command = "chmod +x /data/rc.local"
|
||||||
|
return await run_remote_command(remote_host, command)
|
||||||
|
|
||||||
async def reboot(remote_host):
|
async def reboot(remote_host):
|
||||||
command = "reboot"
|
command = "reboot"
|
||||||
return await run_remote_command(remote_host, command)
|
return await run_remote_command(remote_host, command)
|
||||||
|
@ -144,24 +148,30 @@ async def upload_files(remote_host,which_file):
|
||||||
return f"An error occurred while uploading files: {str(e)}"
|
return f"An error occurred while uploading files: {str(e)}"
|
||||||
|
|
||||||
async def check_connection(remote_host):
|
async def check_connection(remote_host):
|
||||||
# Check if the remote host is reachable
|
result = await run_remote_command(remote_host, 'echo Connection successful')
|
||||||
ping_command = ['ping', '-c', '1', remote_host]
|
return "Connection successful" in result
|
||||||
result = subprocess.run(ping_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
return result.returncode == 0
|
|
||||||
|
|
||||||
async def main(remote_host):
|
async def main(remote_host):
|
||||||
|
##### 1. check connection ######
|
||||||
|
print("Check connection!")
|
||||||
|
if not await check_connection(remote_host):
|
||||||
|
sys.exit("Failed to ssh!")
|
||||||
|
|
||||||
##################################################### Part 1 ################################################################
|
##################################################### Part 1 ################################################################
|
||||||
##### 1. upload VPN and battery files ######
|
|
||||||
print("Upload VPN and battery files!")
|
|
||||||
if(await upload_files(remote_host,1)!="All files uploaded successfully."):
|
|
||||||
sys.exit("Failed to upload files!")
|
|
||||||
else:
|
|
||||||
print(await upload_files(remote_host,1))
|
|
||||||
|
|
||||||
##### 2. update firmware with normal image #####
|
|
||||||
gx_type = await check_GX_type(remote_host)
|
gx_type = await check_GX_type(remote_host)
|
||||||
if gx_type == "einstein\n":
|
if gx_type == "einstein\n":
|
||||||
|
##### 2. upload VPN and battery files ######
|
||||||
|
print("Upload VPN and battery files!")
|
||||||
|
if(await upload_files(remote_host,1)!="All files uploaded successfully."):
|
||||||
|
sys.exit("Failed to upload files!")
|
||||||
|
else:
|
||||||
|
print(await upload_files(remote_host,1))
|
||||||
|
|
||||||
|
##### 3. upload VPN and battery files ######
|
||||||
|
print("Make rc.local executable!")
|
||||||
|
print(await make_rclocal_executable(remote_host))
|
||||||
|
|
||||||
|
##### 4. update firmware with normal image #####
|
||||||
print("Update Cerbo GX firmware now!")
|
print("Update Cerbo GX firmware now!")
|
||||||
print(await update_cerbo_firmware(remote_host))
|
print(await update_cerbo_firmware(remote_host))
|
||||||
else:
|
else:
|
||||||
|
@ -169,23 +179,14 @@ async def main(remote_host):
|
||||||
##################################################### Part 1 ################################################################
|
##################################################### Part 1 ################################################################
|
||||||
|
|
||||||
# Wait for remote computer to come back online
|
# Wait for remote computer to come back online
|
||||||
|
await asyncio.sleep(5)
|
||||||
while not await check_connection(remote_host):
|
while not await check_connection(remote_host):
|
||||||
print("Waiting for remote computer to come back online...")
|
print("Waiting for remote computer to come back online...")
|
||||||
await asyncio.sleep(10) # Adjust timeout as needed
|
await asyncio.sleep(10) # 10 seconds
|
||||||
|
|
||||||
##################################################### Part 2 ################################################################
|
#################################################### Part 2 ################################################################
|
||||||
#### 3. udpate to MK3 #####
|
|
||||||
if (await check_mkVersion(remote_host) == "value = 1170212\n" and await check_allow_mkVersion_update_or_not(remote_host) == "0\n"):
|
|
||||||
print("Update MK3!")
|
|
||||||
print(await update_mkVersion(remote_host))
|
|
||||||
else:
|
|
||||||
print("No need to update to MK3!")
|
|
||||||
|
|
||||||
#### 4. import pika ####
|
#### 5. update firmware with large image ####
|
||||||
print("Import pika!")
|
|
||||||
print(await import_pika(remote_host))
|
|
||||||
|
|
||||||
##### 5. update firmware with large image #####
|
|
||||||
print("Set update feed to official release now!")
|
print("Set update feed to official release now!")
|
||||||
print(await set_official_update_feed(remote_host))
|
print(await set_official_update_feed(remote_host))
|
||||||
print("Enable large image now!")
|
print("Enable large image now!")
|
||||||
|
@ -196,34 +197,54 @@ async def main(remote_host):
|
||||||
print(await update_firmware(remote_host))
|
print(await update_firmware(remote_host))
|
||||||
else:
|
else:
|
||||||
sys.exit("Failed to enable large image!")
|
sys.exit("Failed to enable large image!")
|
||||||
##################################################### Part 2 ################################################################
|
#################################################### Part 2 ################################################################
|
||||||
|
|
||||||
# Wait for remote computer to come back online
|
# Wait for remote computer to come back online
|
||||||
|
await asyncio.sleep(5)
|
||||||
while not await check_connection(remote_host):
|
while not await check_connection(remote_host):
|
||||||
print("Waiting for remote computer to come back online...")
|
print("Waiting for remote computer to come back online...")
|
||||||
await asyncio.sleep(10) # Adjust timeout as needed
|
await asyncio.sleep(10) # 10 seconds
|
||||||
|
|
||||||
##################################################### Part 3 ################################################################
|
##################################################### Part 3 ################################################################
|
||||||
#### 6. resize /dev/root #####
|
#### 6. resize /dev/root #####
|
||||||
print("Resize /dev/root now!")
|
print("Resize /dev/root now!")
|
||||||
print(await resize(remote_host))
|
resize_result = await resize(remote_host)
|
||||||
|
if "Failed" in resize_result:
|
||||||
|
sys.exit(f"Failed to resize: {resize_result}")
|
||||||
|
else:
|
||||||
|
print(resize_result)
|
||||||
|
|
||||||
#### 7. enable Node Red #####
|
#### 7. import pika ####
|
||||||
|
print("Import pika!")
|
||||||
|
import_result = await import_pika(remote_host)
|
||||||
|
if "Failed" in import_result:
|
||||||
|
sys.exit(f"Failed to import pika: {import_result}")
|
||||||
|
else:
|
||||||
|
print(import_result)
|
||||||
|
|
||||||
|
#### 8. udpate to MK3 #####
|
||||||
|
if (await check_mkVersion(remote_host) == "value = 1170212\n" and await check_allow_mkVersion_update_or_not(remote_host) == "0\n"):
|
||||||
|
print("Update MK3!")
|
||||||
|
print(await update_mkVersion(remote_host))
|
||||||
|
else:
|
||||||
|
print("No need to update to MK3!")
|
||||||
|
|
||||||
|
#### 9. enable Node Red #####
|
||||||
print("Enable Node Red now!")
|
print("Enable Node Red now!")
|
||||||
print(await enable_NodeRed(remote_host))
|
print(await enable_NodeRed(remote_host))
|
||||||
if(await check_NodeRed_enabled_or_not(remote_host) == "value = 1\n"):
|
if(await check_NodeRed_enabled_or_not(remote_host) == "value = 1\n"):
|
||||||
##### 8. download Node Red Dashboard #####
|
##### 10. download Node Red Dashboard #####
|
||||||
print("Download Node Red Dashboard now!")
|
print("Download Node Red Dashboard now!")
|
||||||
print(await download_node_red_dashboard(remote_host))
|
print(await download_node_red_dashboard(remote_host))
|
||||||
else:
|
else:
|
||||||
sys.exit("Failed to enable Node Red!")
|
sys.exit("Failed to enable Node Red!")
|
||||||
|
|
||||||
##### 9. upload files related to Node Red #####
|
##### 11. upload files related to Node Red #####
|
||||||
print("Upload files related to Node Red now!")
|
print("Upload files related to Node Red now!")
|
||||||
if(await upload_files(remote_host,2)!="All files uploaded successfully."):
|
if(await upload_files(remote_host,2)!="All files uploaded successfully."):
|
||||||
sys.exit("Failed to upload files!")
|
sys.exit("Failed to upload files!")
|
||||||
|
|
||||||
#### 10. restart Node Red to load and deploy flows #####
|
#### 12. restart Node Red to load and deploy flows #####
|
||||||
print("Disable Node Red!")
|
print("Disable Node Red!")
|
||||||
if(await disable_NodeRed(remote_host) == "retval = 0\n"):
|
if(await disable_NodeRed(remote_host) == "retval = 0\n"):
|
||||||
print("Re-enable Node Red!")
|
print("Re-enable Node Red!")
|
||||||
|
|
Loading…
Reference in New Issue