def self_update(config): internet_flag = internet_check() if not internet_flag: print( f"\t{Bcolors.RED}Looks like you don't have internet connection.{Bcolors.ENDC}" ) sleep(0.5) os.system("./scripts/net_fixer.sh") print("Trying again...") internet_flag = internet_check() if not internet_flag: # don't change to 'elif' - it is second check after a repair! print( f"\t{Bcolors.RED}Looks like you still don't have internet connection. Update canceled.{Bcolors.ENDC}" ) sleep(2) else: print(f"\t\t{Bcolors.GREEN}Internet connection - OK{Bcolors.ENDC}\n") sleep(1.5) make_directories_accessible(config) old_version_name = get_ota_version(True) print( f"\n\n\n\t Please wait: updating process from version {old_version_name}\n\n" ) dots_show(2) # if config: # if config is not empty, then the file exited to load. # shutil.copyfile('~/RH-ota/updater-config.json', '~/.ota_markers/updater-config.json') if config.beta_tester: source = 'master' print( "This will be the 'beta' update - may be changed in config wizard.\n" ) else: source = 'stable' os.system(f"./scripts/self_updater.sh {source}") # if config: # if the config variable is not empty, then the config file must have existed. # shutil.copyfile("~/.ota_markers/old_RH-ota/updater-config.json", "~/RH-ota/updater-config.json") new_version_name = get_ota_version(True) print(f""" RotorHazard OTA Manager updated to version {new_version_name} You may check update-notes. """) sleep(1) make_directories_accessible(config) os.system( "cp ~/.ota_markers/old_RH-ota/updater-config.json ~/RH-ota/updater-config.json" ) # it had some bug with shutil - can be changed when resolved if new_version_name != old_version_name: os.system("echo OTA was updated > ~/.ota_markers/.was_updated_new") else: os.system( "echo OTA was not updated > ~/.ota_markers/.was_updated_old")
def self_update(config): internet_flag = internet_check() if not internet_flag: print( "\nLooks like you don't have internet connection. Update canceled.\n" ) sleep(2) else: print("\nInternet connection - OK\n") sleep(1.5) os.system("sudo chmod -R 777 ~/.ota_markers > /dev/null 2>&1" ) # resolves compatibility issues os.system("sudo chmod -R 777 ~/RH-ota > /dev/null 2>&1" ) # resolves compatibility issues old_version_name = get_ota_version() print( f"\n\n\n\t Please wait: updating process from version {old_version_name}\n\n" ) dots_show(2) source = 0 if config: # if config is not empty, then the file exited to load. shutil.copyfile('~/RH-ota/updater-config.json', '~/.ota_markers/updater-config.json') if config['beta_tester']: source = 'master' print( "This will be 'beta' update - may be changed in config file.\n" ) if not config['beta_tester']: if not config.updates_without_pdf: source = 'main_stable' print( "Update will contain PDF file - may be changed in config file.\n" ) else: source = 'no_pdf' print( "Update won't contain PDF file - may be changed in config file.\n" ) os.system(f". ./scripts/self_updater_actions.sh {source}") if config: # if the config variable is not empty, then the config file must have existed. shutil.copyfile('~/.ota_markers/updater-config.json', '~/RH-ota/updater-config.json"') new_version_name = get_ota_version() print( f"\n\n\n\t RotorHazard OTA Manager updated to version {new_version_name}\ \n\t\tYou may check update-notes.\n\n") sleep(1) os.system("sudo chmod -R 777 ~/.ota_markers > /dev/null 2>&1") os.system("sudo chmod -R 777 ~/RH-ota/*.sh > /dev/null 2>&1" ) # only make the shell scripts executable. if new_version_name != old_version_name: os.system("echo OTA was updated > ~/.ota_markers/.was_updated")
def installation(conf_allowed, config): ota_config = load_ota_sys_markers(config.user) os.system("sudo systemctl stop rotorhazard >/dev/null 2>&1 &" ) if not config.debug_mode else None clear_the_screen() internet_flag = internet_check() if not internet_flag: print( f"\n\t{Bcolors.RED}Looks like you don't have internet connection. Installation canceled.{Bcolors.ENDC}" ) sleep(2) else: print(f"\n\t\t\t{Bcolors.GREEN}Internet connection - OK{Bcolors.ENDC}") sleep(2) clear_the_screen() print( f"\n\n\t{Bcolors.BOLD}Installation process has been started - please wait...{Bcolors.ENDC}\n\n" ) installation_completed = """ ###################################################### ## ## ##{bold}{green}Installation completed {thumbs}{endc}## ## ## ###################################################### After rebooting please check by typing 'sudo raspi-config' if I2C, SPI and SSH protocols are active. """.format(thumbs="👍👍👍 ", bold=Bcolors.BOLD_S, endc=Bcolors.ENDC_S, green=Bcolors.GREEN_S) os.system("./scripts/sys_conf.sh all") if conf_allowed else None ota_config.sys_config_done = True os.system("./scripts/sys_conf.sh uart" ) if not ota_config.uart_support_added else None ota_config.uart_support_added = True # UART enabling added here so user won't have to reboot Pi again after doing it in Features Menu write_ota_sys_markers(ota_config, config.user) os.system( f"./scripts/install_rh.sh {config.user} {check_preferred_rh_version(config)[0]}" ) input("press Enter to continue.") clear_the_screen() print(installation_completed) os.system("sudo chmod 777 -R ~/RotorHazard") end_installation(config.user)
def update(config): os.system("sudo systemctl stop rotorhazard >/dev/null 2>&1 &" ) if not config.debug_mode else None internet_flag = internet_check() if not internet_flag: print( f"\n\t{Bcolors.RED}Looks like you don't have internet connection. Update canceled.{Bcolors.ENDC}" ) sleep(2) else: print(f"\n\t\t\t{Bcolors.GREEN}Internet connection - OK{Bcolors.ENDC}") sleep(2) clear_the_screen() if not os.path.exists(f"/home/{config.user}/RotorHazard"): print(f"""{Bcolors.BOLD} Looks like you don't have RotorHazard server software installed for now. If so please install your server software first.{Bcolors.ENDC}{Bcolors.GREEN} i - Install the software - recommended{Bcolors.ENDC} a - Abort {Bcolors.ENDC} """) selection = input() if selection == 'i': conf_allowed = True installation(conf_allowed, config) elif selection == 'a': clear_the_screen() return else: return else: clear_the_screen() print( f"\n\n\t{Bcolors.BOLD}Updating existing installation - please wait...{Bcolors.ENDC}\n\n" ) os.system( f"./scripts/update_rh.sh {config.user} {check_preferred_rh_version(config)[0]}" ) config_flag, config_soft = check_rotorhazard_config_status(config) server_installed_flag, server_version_name = get_rotorhazard_server_version( config) os.system("sudo chmod -R 777 ~/RotorHazard") end_update(config, config_flag, server_installed_flag)
def update(): if not linux_testing: os.system("sudo systemctl stop rotorhazard >/dev/null 2>&1 &") internet_flag = internet_check(user) if not internet_flag: print("\nLooks like you don't have internet connection. Update canceled.") sleep(2) else: print("\nInternet connection - OK") sleep(2) clear_the_screen() if not os.path.exists(f"/home/{user}/RotorHazard"): print(f"""{Bcolors.BOLD} Looks like you don't have RotorHazard server software installed for now. \n\t\t If so please install your server software first or you won't be able to use the timer.{Bcolors.ENDC}""") print(f"""\n\n{Bcolors.GREEN} 'i' - Install the software - recommended{Bcolors.ENDC}\n 'u' - Force update procedure\n{Bcolors.YELLOW} 'a' - Abort both \n\n{Bcolors.ENDC}""") selection = input() if selection == 'i': conf_allowed = True installation() if selection == 'u': update() if selection == 'a': clear_the_screen() sys.exit() else: main() else: clear_the_screen() print(f"\n\t{Bcolors.BOLD}Updating existing installation - please wait...{Bcolors.ENDC} \n") os.system("sudo -H python -m pip install --upgrade pip") os.system("sudo -H pip install pillow ") os.system("sudo apt-get install libjpeg-dev ntp -y") os.system("sudo apt-get update && sudo apt-get upgrade -y") if not linux_testing: os.system("sudo apt dist-upgrade -y") os.system("sudo apt autoremove -y") if not os.path.exists(f"/home/{user}/.old_RotorHazard.old"): os.system(f"sudo mkdir /home/{user}/.old_RotorHazard.old") os.system(f"sudo cp -r /home/{user}/RotorHazard-* /home/{user}/.old_RotorHazard.old/ >/dev/null 2>&1") os.system(f"sudo rm -r /home/{user}/RotorHazard-master >/dev/null 2>&1") # just in case of weird sys cfg os.system(f"sudo rm -r /home/{user}/temp.zip >/dev/null 2>&1") # just in case of weird sys config if os.path.exists(f"/home/{user}/RotorHazard.old"): os.system(f"sudo cp -r /home/{user}/RotorHazard.old /home/{user}/.old_RotorHazard.old/") os.system(f"sudo rm -r /home/{user}/RotorHazard.old") os.system(f"sudo mv /home/{user}/RotorHazard /home/{user}/RotorHazard.old") os.chdir(f"/home/{user}") os.system(f"wget https://codeload.github.com/RotorHazard/RotorHazard/zip/{server_version} -O temp.zip") os.system("unzip temp.zip") os.system(f"mv /home/{user}/RotorHazard-{server_version} /home/{user}/RotorHazard") os.system("sudo rm temp.zip") os.system(f"sudo mkdir /home/{user}/backup_RH_data >/dev/null 2>&1") os.system(f"sudo chmod 777 -R /home/{user}/RotorHazard/src/server") os.system(f"sudo chmod 777 -R /home/{user}/RotorHazard.old") os.system(f"sudo chmod 777 -R /home/{user}/.old_RotorHazard.old") os.system(f"sudo chmod 777 -R /home/{user}/backup_RH_data") os.system(f"sudo chmod 777 -R /home/{user}/.ota_markers") os.system(f"cp /home/{user}/RotorHazard.old/src/server/config.json \ /home/{user}/RotorHazard/src/server/ >/dev/null 2>&1 &") os.system(f"cp -r /home/{user}/RotorHazard.old/src/server/static/image \ /home/{user}/backup_RH_data") os.system(f"cp -r /home/{user}/RotorHazard.old/src/server/static/image \ /home/{user}/RotorHazard/src/server/static") os.system(f"cp /home/{user}/RotorHazard.old/src/server/config.json \ /home/{user}/backup_RH_data >/dev/null 2>&1 &") os.system(f"cp /home/{user}/RotorHazard.old/src/server/database.db \ /home/{user}/RotorHazard/src/server/ >/dev/null 2>&1 &") os.system(f"cp /home/{user}/RotorHazard.old/src/server/database.db \ /home/{user}/backup_RH_data >/dev/null 2>&1 &") os.chdir(f"/home/{user}/RotorHazard/src/server") os.system("sudo -H pip install --upgrade --no-cache-dir -r requirements.txt") # todo pip3 or pip or what? print("""\n\n\t ############################################## # # #{bold}{green} Update completed! {endc} # # # ############################################## """.format(bold=Bcolors.BOLD_S, endc=Bcolors.ENDC_S, green=Bcolors.GREEN_S) end_update() def main(): global config_flag global serv_installed_flag global conf_allowed global config_soft global server_version_name # todo too much globals clear_the_screen() server_checker() config_checker() sleep(0.1) welcome = """ \n\n{red} {bold} AUTOMATIC UPDATE AND INSTALLATION OF ROTORHAZARD RACING TIMER SOFTWARE\n\t {endc}{bold} You can automatically install and update RotorHazard timing software. Additional dependencies and libraries also will be installed or updated. Current database, configs and custom bitmaps will stay on their place. Source of the software is set to '{blue}{server_version}{endc}'{bold} version from the official RotorHazard repository. Perform self-updating of this software, before updating server software. Also make sure that you are logged as user {blue}'{user}'{endc}{bold}. \n You can change those in configuration wizard in Main Menu.\n Server installed right now: {server} {bold} RotorHazard configuration state: {config_soft}\n\n\n """.format(bold=Bcolors.BOLD, underline=Bcolors.UNDERLINE, endc=Bcolors.ENDC, blue=Bcolors.BLUE, yellow=Bcolors.YELLOW, red=Bcolors.RED, orange=Bcolors.ORANGE, server_version=server_version, user=user, config_soft=config_soft, server=server_version_name, ) print(welcome) if not config_flag and serv_installed_flag: print(f"{Bcolors.GREEN}\t\t'c' - Configure RotorHazard server\n{Bcolors.ENDC}") else: print("\t\t'c' - Reconfigure RotorHazard server\n") if not serv_installed_flag: print(f"\t{Bcolors.GREEN}'i' - Install software from skratch{endc}") else: print("""\t\t'i' - Install software from skratch""") print(""" 'u' - Update existing installation\n {yellow} 'e' - Exit to Main Menu{endc}\n """.format(yellow=Bcolors.YELLOW, endc=Bcolors.ENDC)) selection = input() if selection == 'c': if serv_installed_flag: os.system(". ./open_scripts.sh; rh_configuration_start") else: print("\n\t\tPlease install server software first") sleep(1.5) if selection == 'i': if parser.getint('added_functions', 'installation_done'): clear_the_screen() already_installed_prompt = """ {bold} Looks like you already have RotorHazard server installed (or at least that your system was once configured).{endc}\n If that's the case please use {underline} update mode {endc} - 'u' or force installation {underline} without {endc} sys. config. - 'i'. {green} 'u' - Select update mode - recommended {endc}\n 'i' - Force installation without sys. config.\n 'c' - Force installation and sys. config.\n {yellow} 'a' - Abort both \n {endc}""").format(bold=Bcolors.BOLD, endc=Bcolors.ENDC, underline=Bcolors.UNDERLINE, yellow=Bcolors.YELLOW) print(already_installed_prompt) selection = input() if selection == 'u': update() if selection == 'i': conf_allowed = False installation() if selection == 'c': confirm_valid_options = ['y', 'yes', 'n', 'no', 'abort', 'a'] while True: confirm = input("\n\t\tAre you sure? [yes/abort]\t").strip() if confirm in confirm_valid_options: break else: print("\ntoo big fingers :( wrong command. try again! :)") if confirm == 'y' or confirm == 'yes': conf_allowed = True installation() if confirm in ['n', 'no', 'abort', 'a']: pass if selection == 'a': clear_the_screen() image_show() sleep(0.5) sys.exit() else: main() else:
def installation(): if not linux_testing: os.system("sudo systemctl stop rotorhazard >/dev/null 2>&1 &") internet_flag = internet_check(user) if not internet_flag: print("\nLooks like you don't have internet connection. Installation canceled.") sleep(2) else: print("\nInternet connection - OK") sleep(2) clear_the_screen() print("\n\t" + Bcolors.BOLD + "Installation process has been started - please wait..." + Bcolors.ENDC + " \n") os.system("sudo apt-get update && sudo apt-get upgrade -y") os.system("sudo apt autoremove -y") os.system("sudo apt install wget ntp libjpeg-dev i2c-tools python-dev libffi-dev python-smbus \ build-essential python-pip git scons swig zip -y") if linux_testing: # on Linux PC system os.system("sudo apt dist-upgrade -y") else: # on Raspberry os.system("sudo apt install python-rpi.gpio") if conf_allowed: sys_conf() os.system("sudo -H pip install cffi pillow") os.chdir("/home/" + user) if not os.path.exists(f"/home/{user}/.old_RotorHazard.old"): os.system(f"mkdir /home/{user}/.old_RotorHazard.old") if os.path.exists(f"/home/{user}/RotorHazard"): os.system(f"cp -r /home/{user}/RotorHazard /home/{user}/.old_RotorHazard.old/ >/dev/null 2>&1") # in case of forced installation os.system(f"rm -r /home/{user}/RotorHazard >/dev/null 2>&1") # in case of forced installation os.system(f"rm /home/{user}/temp >/dev/null 2>&1") # in case of forced installation os.system(f"cp -r /home/{user}/RotorHazard-* /home/{user}/.old_RotorHazard.old/ >/dev/null 2>&1") # in case of forced installation os.system(f"rm -r /home/{user}/RotorHazard-* >/dev/null 2>&1") # in case of forced installation os.chdir("/home/" + user) os.system(f"wget https://codeload.github.com/RotorHazard/RotorHazard/zip/{server_version} -O temp.zip") os.system("unzip temp.zip") os.system("rm temp.zip") os.system(f"mv /home/{user}/RotorHazard-{server_version} /home/{user}/RotorHazard") os.system(f"sudo -H pip install -r /home/{user}/RotorHazard/src/server/requirements.txt") os.system(f"sudo chmod 777 -R /home/{user}/RotorHazard/src/server") os.chdir(f"/home/{user}") os.system("sudo git clone https://github.com/jgarff/rpi_ws281x.git") os.chdir(f"/home/{user}/rpi_ws281x") os.system("sudo scons") os.chdir(f"/home/{user}/rpi_ws281x/python") os.system("sudo python setup.py install") os.chdir(f"/home/{user}") os.system("sudo git clone https://github.com/chrisb2/pi_ina219.git") os.chdir(f"/home/{user}/pi_ina219") os.system("sudo python setup.py install") os.chdir(f"/home/{user}") os.system("sudo git clone https://github.com/rm-hull/bme280.git") os.chdir(f"/home/{user}/bme280") os.system("sudo python setup.py install") parser.set('added_functions', 'installation_done', '1') parser_write() os.system("sudo apt-get install openjdk-8-jdk-headless -y") os.system("sudo rm /lib/systemd/system/rotorhazard.service") os.system("echo ' ' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo '[Unit]' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo 'Description=RotorHazard Server' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo 'After=multi-user.target' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo ' ' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo '[Service]' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system(f"echo 'WorkingDirectory=/home/{user}/RotorHazard/src/server' \ | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo 'ExecStart=/usr/bin/python server.py' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo ' ' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo '[Install]' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("echo 'WantedBy=multi-user.target' | sudo tee -a /lib/systemd/system/rotorhazard.service") os.system("sudo chmod 644 /lib/systemd/system/rotorhazard.service") os.system("sudo systemctl daemon-reload") os.system("sudo systemctl enable rotorhazard.service") print("""\n\n ############################################## # # #{bold}{green}Installation completed {endc} # # # ############################################## After rebooting please check by typing 'sudo raspi-config' if I2C, SPI and SSH protocols are active. """.format(bold=Bcolors.BOLD_S, endc=Bcolors.ENDC_S, green=Bcolors.GREEN_S)) end_installation()
def update(): if not linux_testing: os.system("sudo systemctl stop rotorhazard >/dev/null 2>&1 &") internet_flag = internet_check() if not internet_flag: print( "\nLooks like you don't have internet connection. Update canceled." ) sleep(2) else: print("\nInternet connection - OK") sleep(2) clear_the_screen() if not os.path.exists(f"/home/{user}/RotorHazard"): print(f"""{Bcolors.BOLD} Looks like you don't have RotorHazard server software installed for now. \n\t\t If so please install your server software first or you won't be able to use the timer.{Bcolors.ENDC}""" ) print(f"""\n\n{Bcolors.GREEN} 'i' - Install the software - recommended{Bcolors.ENDC}\n 'u' - Force update procedure\n{Bcolors.YELLOW} 'a' - Abort both \n\n{Bcolors.ENDC}""") selection = input() if selection == 'i': conf_allowed = True installation() if selection == 'u': update() if selection == 'a': clear_the_screen() sys.exit() else: main() else: clear_the_screen() print( f"\n\t{Bcolors.BOLD}Updating existing installation - please wait...{Bcolors.ENDC} \n" ) update_completed = """\n\n\t ################################################ ## ## ##{bold}{green}Update completed!{thumbs}{endc}## ## ## ################################################ """.format(thumbs=3 * emoji.emojize(':thumbs_up:') + str(2 * " "), bold=Bcolors.BOLD_S, endc=Bcolors.ENDC_S, green=Bcolors.GREEN_S) os.system(f"./scripts/update_rh.sh {user} {server_version}") # os.system("sudo -H python -m pip install --upgrade pip") # todo David - ok? delete if yes # os.system("sudo -H pip install pillow ") # os.system("sudo apt-get install libjpeg-dev ntp -y") # os.system("sudo apt-get update && sudo apt-get upgrade -y") # if not linux_testing: # os.system("sudo apt dist-upgrade -y") # os.system("sudo apt autoremove -y") # if not os.path.exists(f"/home/{user}/.old_RotorHazard.old"): # os.system(f"sudo mkdir /home/{user}/.old_RotorHazard.old") # os.system(f"sudo cp -r /home/{user}/RotorHazard-* /home/{user}/.old_RotorHazard.old/ >/dev/null 2>&1") # os.system(f"sudo rm -r /home/{user}/RotorHazard-master >/dev/null 2>&1") # just in case of weird sys cfg # os.system(f"sudo rm -r /home/{user}/temp.zip >/dev/null 2>&1") # just in case of weird sys config # if os.path.exists(f"/home/{user}/RotorHazard.old"): # os.system(f"sudo cp -r /home/{user}/RotorHazard.old /home/{user}/.old_RotorHazard.old/") # os.system(f"sudo rm -r /home/{user}/RotorHazard.old") # os.system(f"sudo mv /home/{user}/RotorHazard /home/{user}/RotorHazard.old") # os.chdir(f"/home/{user}") # os.system(f"wget https://codeload.github.com/RotorHazard/RotorHazard/zip/{server_version} -O temp.zip") # os.system("unzip temp.zip") # os.system(f"mv /home/{user}/RotorHazard-{server_version} /home/{user}/RotorHazard") # os.system("sudo rm temp.zip") # os.system(f"sudo mkdir /home/{user}/backup_RH_data >/dev/null 2>&1") # os.system(f"sudo chmod 777 -R /home/{user}/RotorHazard/src/server") # os.system(f"sudo chmod 777 -R /home/{user}/RotorHazard.old") # os.system(f"sudo chmod 777 -R /home/{user}/.old_RotorHazard.old") # os.system(f"sudo chmod 777 -R /home/{user}/backup_RH_data") # os.system(f"sudo chmod 777 -R /home/{user}/.ota_markers") # os.system(f"cp /home/{user}/RotorHazard.old/src/server/config.json \ # /home/{user}/RotorHazard/src/server/ >/dev/null 2>&1 &") # os.system(f"cp -r /home/{user}/RotorHazard.old/src/server/static/image \ # /home/{user}/backup_RH_data") # os.system(f"cp -r /home/{user}/RotorHazard.old/src/server/static/image \ # /home/{user}/RotorHazard/src/server/static") # os.system(f"cp /home/{user}/RotorHazard.old/src/server/config.json \ # /home/{user}/backup_RH_data >/dev/null 2>&1 &") # os.system(f"cp /home/{user}/RotorHazard.old/src/server/database.db \ # /home/{user}/RotorHazard/src/server/ >/dev/null 2>&1 &") # os.system(f"cp /home/{user}/RotorHazard.old/src/server/database.db \ # /home/{user}/backup_RH_data >/dev/null 2>&1 &") # os.chdir(f"/home/{user}/RotorHazard/src/server") # os.system("sudo pip install --upgrade --no-cache-dir -r requirements.txt") print(update_completed) end_update(config_checker()[0], server_version_checker()[0])
def installation(conf_allowed): if not linux_testing: os.system("sudo systemctl stop rotorhazard >/dev/null 2>&1 &") internet_flag = internet_check() if not internet_flag: print( "\nLooks like you don't have internet connection. Installation canceled." ) sleep(2) else: print("\nInternet connection - OK") sleep(2) clear_the_screen() print( f"\n\t{Bcolors.BOLD}Installation process has been started - please wait...{Bcolors.ENDC}\n" ) installation_completed = """\n\n ##################################################### ## ## ##{bold}{green}Installation completed{thumbs}{endc}## ## ## ##################################################### After rebooting please check by typing 'sudo raspi-config' if I2C, SPI and SSH protocols are active. """.format(thumbs=3 * emoji.emojize(':thumbs_up:') + str(2 * " "), bold=Bcolors.BOLD_S, endc=Bcolors.ENDC_S, green=Bcolors.GREEN_S) try: os.system(f"./scripts/install_rh.sh {user} {server_version}") if conf_allowed: os.system("sh. ./scripts/sys_conf.sh") config_soft['installation_done'] = 1 if pi_4_FLAG: os.system( "sed -i 's/core_freq=250/#core_freq=250/' /boot/config.txt > /dev/null 2>&1" ) config_soft[ 'installation_performed'] = true # todo change to this json something json.dump() # sys_config_etc print(installation_completed) except: # todo add something print("Error occurred. Installation aborted.") # os.system("sudo apt-get update && sudo apt-get upgrade -y") # todo David - ok? delete if yes # os.system("sudo apt autoremove -y") # os.system("sudo apt install wget ntp libjpeg-dev i2c-tools python-dev libffi-dev python-smbus \ # build-essential python-pip git scons swig zip -y") # if linux_testing: # on Linux PC system # os.system("sudo apt dist-upgrade -y") # else: # on Raspberry # os.system("sudo apt install python-rpi.gpio") # if conf_allowed: # sys_conf() # os.system("sudo -H pip install cffi pillow") # os.chdir("/home/" + user) # if not os.path.exists(f"/home/{user}/.old_RotorHazard.old"): # os.system(f"mkdir /home/{user}/.old_RotorHazard.old") # if os.path.exists(f"/home/{user}/RotorHazard"): # os.system(f"cp -r /home/{user}/RotorHazard /home/{user}/.old_RotorHazard.old/ >/dev/null 2>&1") # # in case of forced installation # os.system(f"rm -r /home/{user}/RotorHazard >/dev/null 2>&1") # in case of forced installation # os.system(f"rm /home/{user}/temp >/dev/null 2>&1") # in case of forced installation # os.system(f"cp -r /home/{user}/RotorHazard-* /home/{user}/.old_RotorHazard.old/ >/dev/null 2>&1") # # in case of forced installation # os.system(f"rm -r /home/{user}/RotorHazard-* >/dev/null 2>&1") # in case of forced installation # os.chdir(f"/home/{user}") # os.system(f"wget https://codeload.github.com/RotorHazard/RotorHazard/zip/{server_version} -O temp.zip") # os.system("unzip temp.zip") # os.system("rm temp.zip") # os.system(f"mv /home/{user}/RotorHazard-{server_version} /home/{user}/RotorHazard") # os.system(f"sudo -H pip install -r /home/{user}/RotorHazard/src/server/requirements.txt") # os.system(f"sudo chmod 777 -R /home/{user}/RotorHazard/src/server") # os.chdir(f"/home/{user}") # os.system("sudo git clone https://github.com/jgarff/rpi_ws281x.git") # os.chdir(f"/home/{user}/rpi_ws281x") # os.system("sudo scons") # os.chdir(f"/home/{user}/rpi_ws281x/python") # os.system("sudo python setup.py install") # os.chdir(f"/home/{user}") # os.system("sudo git clone https://github.com/chrisb2/pi_ina219.git") # os.chdir(f"/home/{user}/pi_ina219") # os.system("sudo python setup.py install") # os.chdir(f"/home/{user}") # os.system("sudo git clone https://github.com/rm-hull/bme280.git") # os.chdir(f"/home/{user}/bme280") # os.system("sudo python setup.py install") # config_soft['installation_done'] = 1 # json.dump() # soft config # os.system("sudo apt-get install openjdk-8-jdk-headless -y") # os.system("sudo rm /lib/systemd/system/rotorhazard.service") # os.system("echo ' ' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo '[Unit]' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo 'Description=RotorHazard Server' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo 'After=multi-user.target' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo ' ' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo '[Service]' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system(f"echo 'WorkingDirectory=/home/{user}/RotorHazard/src/server' \ # | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo 'ExecStart=/usr/bin/python server.py' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo ' ' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo '[Install]' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("echo 'WantedBy=multi-user.target' | sudo tee -a /lib/systemd/system/rotorhazard.service") # os.system("sudo chmod 644 /lib/systemd/system/rotorhazard.service") # os.system("sudo systemctl daemon-reload") # os.system("sudo systemctl enable rotorhazard.service") end_installation()
def main(): config = load_config() internet_check() self_update(config)