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 Init") If gName <> "root" PrintN("You need to run this app as root capable user") End EndIf PrintN("Create lhttpd config: /etc/lhttpd/lhttpd.cfg") PrintN("Create service file: /usr/lib/systemd/system/lhttpd.service") 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("/var/lib/lhttpd") 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) PrintN("Create config") CreatePreferences("/etc/lhttpd/lhttpd.cfg", #PB_Preference_NoSpace | #PB_Preference_GroupSeparator) PreferenceGroup("lhttpd") WritePreferenceString("HTTP_Port","8080") WritePreferenceString("HTTP_Binding","0.0.0.0") WritePreferenceString("HTTPS_CA","/etc/lhttpd/ssl/sample/fullchain.pem") WritePreferenceString("HTTPS_Cert","/etc/lhttpd/ssl/sample/cert.pem") WritePreferenceString("HTTPS_Key","/etc/lhttpd/ssl/sample/privkey.pem") WritePreferenceString("HTTPS_Key_Pass","test-server-pass") WritePreferenceString("HTTPS_Port","8443") WritePreferenceString("HTTPS_Binding","0.0.0.0") WritePreferenceString("HTTPS_enable","1") WritePreferenceString("Defaultfile","/index.html") WritePreferenceString("Basedirectory","/srv/www/htdocs") WritePreferenceString("Error400_Handling","integrated") WritePreferenceString("Max_HTTP_Clients","10") WritePreferenceString("Max_HTTPS_Clients","100") WritePreferenceString("Filememorycache","0") WritePreferenceString("Checkrun","/tmp/lhttpd.run") WritePreferenceString("Debug_logfile","/var/log/lhttpd/debug.log") WritePreferenceString("Debug_disable","true") WritePreferenceString("Access_logfile","/var/log/lhttpd/access.log") WritePreferenceString("Error_logfile","/var/log/lhttpd/error.log") ClosePreferences() PrintN("chown and chmod for ssl...") RunProgram("chown", "-R lhttpd:lhttpd /etc/lhttpd","", #PB_Program_Wait) RunProgram("chown", "-R lhttpd:lhttpd /var/lib/lhttpd","", #PB_Program_Wait) RunProgram("chown", "-R lhttpd:lhttpd /var/log/lhttpd","", #PB_Program_Wait) RunProgram("chmod", "-r 755 /etc/lhttpd","",#PB_Program_Wait) RunProgram("chmod", "-r 700 /etc/lhttpd/ssl","",#PB_Program_Wait) PrintN("create service file...") 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=0") WriteStringN(0,"") WriteStringN(0,"[Service]") WriteStringN(0,"Type=simple") WriteStringN(0,"Restart=always") WriteStringN(0,"RestartSec=1") WriteStringN(0,"User=lhttpd") WriteStringN(0,"PIDFile=/tmp/lhttpd.run") WriteStringN(0,"ExecStart=/opt/lhttpd/lhttpd") WriteStringN(0,"ExecStop=/bin/rm /tmp/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 End