update Venus rollout script and guidance

This commit is contained in:
Yinyin Liu 2024-07-31 15:31:54 +02:00
parent 2bc09112ae
commit 2fecc345db
2 changed files with 50 additions and 17 deletions

View File

@ -29,14 +29,22 @@ async def run_rclocal(remote_host):
return await run_remote_command(remote_host, command)
async def stop_battery_service(remote_host):
command = "/opt/victronenergy/serial-starter/stop-tty.sh ttyUSB0"
# command = "/opt/victronenergy/serial-starter/stop-tty.sh ttyUSB1"
return await run_remote_command(remote_host, command)
command1 = "cd /opt/victronenergy/serial-starter && ./stop-tty.sh ttyUSB0"
command2 = "cd /opt/victronenergy/serial-starter && ./stop-tty.sh ttyUSB1"
result1 = await run_remote_command(remote_host, command1)
result2 = await run_remote_command(remote_host, command2)
return result1, result2
async def start_battery_service(remote_host):
command = "/opt/victronenergy/serial-starter/start-tty.sh ttyUSB0"
# command = "/opt/victronenergy/serial-starter/start-tty.sh ttyUSB1"
return await run_remote_command(remote_host, command)
command1 = "cd /opt/victronenergy/serial-starter && ./start-tty.sh ttyUSB0"
command2 = "cd /opt/victronenergy/serial-starter && ./start-tty.sh ttyUSB1"
result1 = await run_remote_command(remote_host, command1)
result2 = await run_remote_command(remote_host, command2)
return result1, result2
async def resize(remote_host):
command = "sh /opt/victronenergy/swupdate-scripts/resize2fs.sh"
@ -96,30 +104,55 @@ async def import_pika(remote_host):
command = f"{change_dir_command} && {install_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 check_connection(remote_host):
result = await run_remote_command(remote_host, 'echo Connection successful')
return "Connection successful" in result
async def restart_gui(remote_host):
command1 = "svc -d /service/gui"
command2 = "svc -u /service/gui"
result1 = await run_remote_command(remote_host, command1)
result2 = await run_remote_command(remote_host, command2)
return result1, result2
async def main(remote_host):
##### 1. check whether it's Venus ######
##### 1. check connection ######
print("Check connection!")
if not await check_connection(remote_host):
sys.exit("Failed to ssh!")
##### 2. check whether it's Venus ######
gx_type = await check_GX_type(remote_host)
if gx_type == "beaglebone\n":
##### 2. upload VPN and battery files ######
##### 3. upload VPN and battery files ######
print("Upload pika and battery files!")
if(await upload_files(remote_host)!="All files uploaded successfully."):
sys.exit("Failed to upload files!")
else:
print(await upload_files(remote_host))
#### 3. import pika ####
#### 4. import pika ####
print("Import pika!")
print(await import_pika(remote_host))
#### 4. resize /dev/root #####
#### 5. resize /dev/root #####
print("Resize /dev/root now!")
print(await resize(remote_host))
# ##### 5. run rc.local ######
# print("Run rc.local to set password, timezone and cp battery folder!")
# print(await run_rclocal(remote_host))
##### 5. reboot to run rc.local and update qml ######
print("Reboot!")
#### 6. stop battery service ######
print("Stop battery service!")
print(await stop_battery_service(remote_host))
##### 7. run rc.local ######
print("Run rc.local!")
print(await run_rclocal(remote_host))
##### 8. start battery service ######
print("Start battery service!")
print(await start_battery_service(remote_host))
##### 9. restart gui ######
print("Restart gui!")
print(await restart_gui(remote_host))
else:
sys.exit("It's not Venus GX!")