new install routine .... alpha release git add installation.pb !
This commit is contained in:
parent
5d82ee5704
commit
61342616b4
2 changed files with 153 additions and 107 deletions
107
createini.pb
107
createini.pb
|
@ -1,107 +0,0 @@
|
|||
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
|
153
installation.pb
Normal file
153
installation.pb
Normal file
|
@ -0,0 +1,153 @@
|
|||
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/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")
|
||||
End
|
||||
EndIf
|
||||
RunProgram("chmod", "777 /tmp/install.sh", "", #PB_Program_Wait)
|
||||
Delay(1000)
|
||||
RunProgram("/tmp/install.sh", "", "", #PB_Program_Wait)
|
||||
|
||||
DeleteFile("/tmp/install.sh")
|
||||
|
||||
; 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("chown", "-R lhttpd:lhttpd /opt/lhttpd","", #PB_Program_Wait)
|
||||
; RunProgram("chmod", "-R 744 /etc/lhttpd","",#PB_Program_Wait)
|
||||
; RunProgram("chmod", "-R 744 /etc/lhttpd/hosts","",#PB_Program_Wait)
|
||||
; RunProgram("chmod", "-R 700 /etc/lhttpd/ssl","",#PB_Program_Wait)
|
||||
; RunProgram("chown", "-R 755 /opt/lhttpd","",#PB_Program_Wait)
|
||||
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
|
Loading…
Reference in a new issue