Structure GROUP gr_name.s ; group name gr_passwd.s ; group password gr_gid.i ; group id gr_mem.i ; group members EndStructure Global gID.i = getgid_() Global group.group Global gName.s Global eingabe.s *groupmem = AllocateMemory(SizeOf(group)) *groupmem = getgrgid_(gID) CopyMemory(*groupmem, @group, SizeOf(group)) gName = PeekS(@group\gr_name, -1, #PB_Ascii) OpenConsole("lhttpd installation") If gName <> "root" PrintN("You need to run this app as root capable user") End EndIf PrintN("Create lhttpd config: /etc/lhttpd/lhttpd.xml") PrintN("Logfiles /var/log/lhttpd/* (access.log & error.log)") PrintN("User = lhttpd") PrintN("Grounp = lhttpd") PrintN("Everything Ok (y/n)") eingabe = Input() If eingabe <> "y" PrintN("Bad: "+eingabe+" exit...") End EndIf PrintN("Create dir...") CreateDirectory("/etc/lhttpd") CreateDirectory("/etc/lhttpd/ssl") CreateDirectory("/etc/lhttpd/hosts") CreateDirectory("/var/lib/lhttpd") CreateDirectory("/var/lib/lhttpd/default") CreateDirectory("/var/log/lhttpd") CreateDirectory("/opt/lhttpd") PrintN("Create group lhttpd") RunProgram("groupadd", "-f lhttpd", "", #PB_Program_Wait) Delay(1000) PrintN("Create User lhttpd") RunProgram("useradd", "-s /bin/false -b /var/lib -g lhttpd lhttpd","", #PB_Program_Wait) RunProgram("usermod", "-G wwwrun lhttpd","", #PB_Program_Wait) PrintN("Copy config") CopyFile("cfg/lhttpd.xml", "/etc/lhttpd/lhttpd.xml") CopyFile("cfg/default_http_status_codes.xml", "/etc/lhttpd/default_http_status_codes.xml") CopyFile("cfg/hosts/default.xml", "/etc/lhttpd/hosts/default.xml") PrintN("Copy application") CopyFile("lhttpd", "/opt/lhttpd/lhttpd") PrintN("chown and chmod for ssl...") If CreateFile(0, "/tmp/lhttpd_install.sh") WriteStringN(0, "#!/bin/bash") WriteStringN(0, "echo 'started'") WriteStringN(0, "chown -R lhttpd:lhttpd /etc/lhttpd") WriteStringN(0, "chown -R lhttpd:lhttpd /var/lib/lhttpd") WriteStringN(0, "chown -R lhttpd:lhttpd /var/log/lhttpd") WriteStringN(0, "chown -R lhttpd:lhttpd /opt/lhttpd") WriteStringN(0, "chmod -R 644 /etc/lhttpd/*") WriteStringN(0, "chmod 755 /etc/lhttpd") WriteStringN(0, "chmod 755 /etc/lhttpd/hosts") WriteStringN(0, "chmod -R 600 /etc/lhttpd/ssl") WriteStringN(0, "chmod 700 /etc/lhttpd/ssl") WriteStringN(0, "chmod 755 /opt/lhttpd") WriteStringN(0, "chmod 555 /opt/lhttpd/lhttpd") WriteStringN(0, "echo 'finished'") CloseFile(0) Else PrintN("Error : Unable To create script at /tmp/lhttpd_install.sh") End EndIf RunProgram("chmod", "777 /tmp/lhttpd_install.sh", "", #PB_Program_Wait) Delay(1000) RunProgram("/tmp/lhttpd_install.sh", "", "", #PB_Program_Wait) DeleteFile("/tmp/lhttpd_install.sh") PrintN("Create service file: /usr/lib/systemd/system/lhttpd.service") If CreateFile(0, "/usr/lib/systemd/system/lhttpd.service") WriteStringN(0,"[Unit]") WriteStringN(0,"Description=Lweb httpd server") WriteStringN(0,"After=network.target") WriteStringN(0,"StartLimitIntervalSec=90") WriteStringN(0,"") WriteStringN(0,"[Service]") WriteStringN(0,"AmbientCapabilities=CAP_NET_BIND_SERVICE") WriteStringN(0,"Type=simple") WriteStringN(0,"Restart=always") WriteStringN(0,"RestartSec=1") WriteStringN(0,"User=lhttpd") WriteStringN(0,"Group=lhttpd") WriteStringN(0,"PIDFile=/var/lib/lhttpd/lhttpd.run") WriteStringN(0,"ExecStartPre=/bin/touch /var/lib/lhttpd/lhttpd.run") WriteStringN(0,"ExecStart=/opt/lhttpd/lhttpd --run=/var/lib/lhttpd/lhttpd.run --config=/etc/lhttpd/lhttpd.xml") WriteStringN(0,"ExecStop=/bin/rm /var/lib/lhttpd/lhttpd.run") WriteStringN(0,"") WriteStringN(0,"[Install]") WriteStringN(0,"WantedBy=multi-user.target") CloseFile(0) PrintN("daemon reload...") RunProgram("systemctl", "daemon-reload", "", #PB_Program_Wait) PrintN("tests...") RunProgram("systemctl", "status lhttpd", "", #PB_Program_Wait) PrintN("finished") Else PrintN("Servicefile failed") EndIf If CreateFile(0, "/usr/lib/systemd/system/lhttpd-debug.service") WriteStringN(0,"[Unit]") WriteStringN(0,"Description=Lweb httpd server") WriteStringN(0,"After=network.target") WriteStringN(0,"StartLimitIntervalSec=90") WriteStringN(0,"") WriteStringN(0,"[Service]") WriteStringN(0,"AmbientCapabilities=CAP_NET_BIND_SERVICE") WriteStringN(0,"Type=simple") WriteStringN(0,"Restart=always") WriteStringN(0,"RestartSec=1") WriteStringN(0,"User=lhttpd") WriteStringN(0,"Group=lhttpd") WriteStringN(0,"PIDFile=/var/lib/lhttpd/lhttpd.run") WriteStringN(0,"ExecStartPre=/bin/touch /var/lib/lhttpd/lhttpd.run") WriteStringN(0,"ExecStart=/opt/lhttpd/lhttpd --debug=/var/log/lhttpd/debug.log --run=/var/lib/lhttpd/lhttpd.run --config=/etc/lhttpd/lhttpd.xml") WriteStringN(0,"ExecStop=/bin/rm /var/lib/lhttpd/lhttpd.run") WriteStringN(0,"") WriteStringN(0,"[Install]") WriteStringN(0,"WantedBy=multi-user.target") CloseFile(0) PrintN("daemon reload...") RunProgram("systemctl", "daemon-reload", "", #PB_Program_Wait) PrintN("tests...") RunProgram("systemctl", "status lhttpd-debug", "", #PB_Program_Wait) PrintN("finished") Else PrintN("Servicefile failed") EndIf End