Пример #1
0
 def __set_swap_size(self) -> None:
     toolbox.copy_file("templates/dphys-swapfile", "/etc/dphys-swapfile")
     toolbox.replace_string_in_file(
         "/etc/dphys-swapfile",
         "CONF_SWAPSIZE=100",
         "CONF_SWAPSIZE=" + str(self.__config.swap_mb),
     )
     self.__needs_reboot = True
Пример #2
0
 def __prepare_update_packages_script(self) -> None:
     toolbox.call_bash_command("mkdir -p /home/pi/temp")
     toolbox.copy_file("templates/updating", "/home/pi/temp/updating")
     if not toolbox.check_string_in_file("/etc/rc.local",
                                         "/home/pi/temp/updating"):
         toolbox.replace_string_in_file("/etc/rc.local", "exit 0",
                                        "/home/pi/temp/updating")
         toolbox.append_to_file("/etc/rc.local", "exit 0")
     self.__needs_reboot = True
Пример #3
0
 def __set_network_settings(self) -> None:
     toolbox.copy_file("templates/dhcpcd.conf", "/etc/dhcpcd.conf")
     for network_config in self.__config.network_config:
         toolbox.append_to_file("/etc/dhcpcd.conf",
                                f"interface {network_config.interface}")
         toolbox.append_to_file(
             "/etc/dhcpcd.conf",
             f"static ip_address={network_config.ip_address}")
         toolbox.append_to_file("/etc/dhcpcd.conf",
                                f"static routers={network_config.routers}")
         toolbox.append_to_file(
             "/etc/dhcpcd.conf",
             f"static domain_name_servers={' '.join(network_config.domain_name_servers)}",
         )
         toolbox.append_to_file("/etc/dhcpcd.conf", "")
     self.__needs_reboot = True
Пример #4
0
 def __set_wifi_settings(self) -> None:
     toolbox.copy_file("templates/wpa_supplicant.conf",
                       "/etc/wpa_supplicant/wpa_supplicant.conf")
     if self.__config.wifi_settings:
         toolbox.replace_string_in_file(
             "/etc/wpa_supplicant/wpa_supplicant.conf",
             "WLAN_country_code",
             str(self.__config.wifi_settings.country),
         )
         toolbox.replace_string_in_file(
             "/etc/wpa_supplicant/wpa_supplicant.conf",
             "WLAN-SSID",
             str(self.__config.wifi_settings.ssid),
         )
         toolbox.replace_string_in_file(
             "/etc/wpa_supplicant/wpa_supplicant.conf",
             "WLAN-PASSWORT",
             str(self.__config.wifi_settings.psk),
         )
         toolbox.call_bash_command("rfkill unblock 0")
     self.__needs_reboot = True
Пример #5
0
 def __set_locale_en_us(self) -> None:
     toolbox.copy_file("templates/locale.gen", "/etc/locale.gen")
     toolbox.copy_file("templates/locale", "/etc/default/locale")
     toolbox.call_bash_command("dpkg-reconfigure -f noninteractive locales")
     toolbox.check_and_append_to_file("/home/pi/.bashrc", "export LC_ALL=C")
     self.__needs_reboot = True
Пример #6
0
 def __reduce_journald_size(self) -> None:
     toolbox.copy_file(
         "templates/journald.conf",
         "/etc/systemd/journald.conf",
     )
     self.__needs_reboot = True