2021-05-25 17:04:24 +02:00
|
|
|
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")
|
2021-05-26 11:41:59 +02:00
|
|
|
CreateDirectory("/var/log/lhttpd")
|
|
|
|
CreateDirectory("/opt/lhttpd")
|
|
|
|
|
2021-05-25 17:04:24 +02:00
|
|
|
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)
|
2020-11-30 09:53:14 +01:00
|
|
|
PreferenceGroup("lhttpd")
|
2021-05-26 11:41:59 +02:00
|
|
|
WritePreferenceString("HTTP_Port","8080")
|
2020-11-30 09:53:14 +01:00
|
|
|
WritePreferenceString("HTTP_Binding","0.0.0.0")
|
2021-05-26 11:41:59 +02:00
|
|
|
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")
|
2020-11-30 09:53:14 +01:00
|
|
|
WritePreferenceString("HTTPS_Key_Pass","test-server-pass")
|
2021-06-06 09:04:05 +02:00
|
|
|
WritePreferenceString("HTTPS_Port","8443")
|
2021-05-26 11:41:59 +02:00
|
|
|
WritePreferenceString("HTTPS_Binding","0.0.0.0")
|
|
|
|
WritePreferenceString("HTTPS_enable","1")
|
2020-11-30 09:53:14 +01:00
|
|
|
WritePreferenceString("Defaultfile","/index.html")
|
2021-05-25 17:04:24 +02:00
|
|
|
WritePreferenceString("Basedirectory","/srv/www/htdocs")
|
2020-11-30 09:53:14 +01:00
|
|
|
WritePreferenceString("Error400_Handling","integrated")
|
2020-11-30 10:04:29 +01:00
|
|
|
WritePreferenceString("Max_HTTP_Clients","10")
|
|
|
|
WritePreferenceString("Max_HTTPS_Clients","100")
|
2020-11-30 09:53:14 +01:00
|
|
|
WritePreferenceString("Filememorycache","0")
|
2021-05-25 17:04:24 +02:00
|
|
|
WritePreferenceString("Checkrun","/tmp/lhttpd.run")
|
2021-05-26 11:41:59 +02:00
|
|
|
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")
|
2020-11-30 09:53:14 +01:00
|
|
|
ClosePreferences()
|
2021-05-25 17:04:24 +02:00
|
|
|
PrintN("chown and chmod for ssl...")
|
2021-05-26 11:41:59 +02:00
|
|
|
|
2021-05-25 17:04:24 +02:00
|
|
|
RunProgram("chown", "-R lhttpd:lhttpd /etc/lhttpd","", #PB_Program_Wait)
|
2021-05-26 11:41:59 +02:00
|
|
|
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)
|
2021-05-25 17:04:24 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2020-11-30 09:53:14 +01:00
|
|
|
End
|