diff --git a/install-little-backup-box.sh b/install-little-backup-box.sh index 98f105c..d94ccb7 100755 --- a/install-little-backup-box.sh +++ b/install-little-backup-box.sh @@ -169,7 +169,7 @@ sudo DEBIAN_FRONTEND=noninteractive \ -o "Dpkg::Options::=--force-confold" \ -o "Dpkg::Options::=--force-confdef" \ install -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages \ - acl git screen rsync exfat-fuse exfatprogs ntfs-3g acl bindfs gphoto2 libimage-exiftool-perl php php-cli samba samba-common-bin vsftpd imagemagick curl libimobiledevice6 ifuse sshpass f3 sqlite3 php-sqlite3 ffmpeg libheif-examples libraw-bin openvpn wireguard openresolv hfsprogs fuse3 python3 python3-pip python3-pil python3-configobj python3-gpiozero python3-rpi-lgpio python3-qrcode smartmontools dos2unix + acl git screen rsync exfat-fuse exfatprogs ntfs-3g acl bindfs gphoto2 libimage-exiftool-perl php php-cli samba samba-common-bin vsftpd imagemagick curl libimobiledevice6 ifuse sshpass f3 sqlite3 php-sqlite3 ffmpeg libheif-examples libraw-bin openvpn wireguard openresolv hfsprogs fuse3 python3 python3-pip python3-pil python3-configobj python3-gpiozero python3-rpi-lgpio python3-qrcode python3-psutil smartmontools dos2unix # Remove packages not needed anymore if [ "${SCRIPT_MODE}" = "update" ]; then @@ -571,6 +571,22 @@ sudo service vsftpd restart # setup graphical environment source "${INSTALLER_DIR}/setup-graphical-environment.sh" +# eth0 settings: use IPv4, not IPv6 +# echo "[Unit] +# Description=DHCP Client on eth0 +# After=network.target +# +# [Service] +# Type=simple +# ExecStart=/sbin/dhclient -4 -d eth0 +# Restart=always +# +# [Install] +# WantedBy=multi-user.target" | sudo tee /etc/systemd/system/dhclient-eth0.service +# +# sudo systemctl enable dhclient-eth0 +# sudo systemctl start dhclient-eth0 + # install comitup if [ "${SCRIPT_MODE}" = "install" ] || [ "${CHOICE_COMITUP}" = "0" ]; then diff --git a/scripts/displaymenu.py b/scripts/displaymenu.py index a2af885..db5fe93 100644 --- a/scripts/displaymenu.py +++ b/scripts/displaymenu.py @@ -29,11 +29,12 @@ import lib_cron_ip import lib_language import lib_network +import lib_setup import lib_storage import lib_system -import lib_debug -xxx = lib_debug.debug() +# import lib_debug +# xx = lib_debug.debug() class MENU_CONTROLLER(object): def __init__(self): @@ -512,9 +513,6 @@ def move_left(self): ##debug if __name__ == "__main__": - xxx.d('start') - import lib_setup - setup=lib_setup.setup() menu_controller = MENU_CONTROLLER() @@ -541,4 +539,3 @@ def move_left(self): #menuobj.move_right(0)#debug #menuobj.move_right(0)#debug # time.sleep(20) - xxx.d('End.') diff --git a/scripts/lib_comitup.py b/scripts/lib_comitup.py index ed612f0..d2bbb55 100644 --- a/scripts/lib_comitup.py +++ b/scripts/lib_comitup.py @@ -19,6 +19,7 @@ import base64 import os +import psutil import subprocess import sys @@ -26,6 +27,8 @@ import lib_language import lib_setup +# import lib_debug +# xx=lib_debug.debug() class comitup(object): def __init__(self): @@ -80,20 +83,13 @@ def new_status(self, status): for Port in BasicPorts: f.write(f'Listen {Port}\n') - if len(sys.argv) > 1: - if status == 'CONNECTED': - f.write(f'Listen 80\n') + if not self.check_hotspot(): + f.write(f'Listen 80\n') subprocess.run('service apache2 restart || service apache2 start', shell=True) def check_hotspot(self): - try: - if '10.41.0.1' in subprocess.check_output(['sudo', 'ifconfig']).decode(): - return('active') - else: - return('inactive') - except: - return('Error') + return(len([p for p in psutil.process_iter() if 'comitup-web' in p.name()]) > 0) def reset(self): subprocess.run(['sudo', 'comitup-cli', 'd']) @@ -124,7 +120,7 @@ def reset(self): comitup().new_status(Status) elif Mode == '--check_hotspot': - print(comitup().check_hotspot()) + print('active' if comitup().check_hotspot() else 'inactive') elif Mode == '--reset': comitup().reset()