]> git.pld-linux.org Git - packages/h2o.git/commitdiff
add init scripts, lograote and index page
authorElan Ruusamäe <glen@pld-linux.org>
Fri, 29 Sep 2017 12:30:46 +0000 (15:30 +0300)
committerElan Ruusamäe <glen@pld-linux.org>
Fri, 29 Sep 2017 12:37:35 +0000 (15:37 +0300)
from https://github.com/tatsushid/h2o-rpm @843dc25

h2o.conf [new file with mode: 0644]
h2o.init [new file with mode: 0644]
h2o.logrotate [new file with mode: 0644]
h2o.service [new file with mode: 0644]
h2o.spec
h2o.tmpfiles [new file with mode: 0644]
index.html [new file with mode: 0644]

diff --git a/h2o.conf b/h2o.conf
new file mode 100644 (file)
index 0000000..3630a24
--- /dev/null
+++ b/h2o.conf
@@ -0,0 +1,22 @@
+user: nobody
+hosts:
+  "localhost:443":
+    listen:
+      port: 443
+      host: 0.0.0.0
+      ssl:
+        certificate-file: "/etc/pki/tls/certs/localhost.crt"
+        key-file: "/etc/pki/tls/private/localhost.key"
+    paths:
+      "/":
+        file.dir: /var/www/html
+  "localhost:80":
+    listen:
+      port: 80
+      host: 0.0.0.0
+    paths:
+      "/":
+        file.dir: /var/www/html
+access-log: /var/log/h2o/access.log
+error-log: /var/log/h2o/error.log
+pid-file: /var/run/h2o/h2o.pid
diff --git a/h2o.init b/h2o.init
new file mode 100644 (file)
index 0000000..7eb0659
--- /dev/null
+++ b/h2o.init
@@ -0,0 +1,111 @@
+#!/bin/bash
+#
+# chkconfig: - 85 15
+# description: H2O - the optimized HTTP/1, HTTP/2 server
+# processname: h2o
+# config: /etc/h2o/h2o.conf
+# pidfile: /var/run/h2o/h2o.pid
+
+### BEGIN INIT INFO
+# Provides: h2o
+# Required-Start: $local_fs $remote_fs $network $named
+# Required-Stop: $local_fs $remote_fs $network
+# Should-Start: distcache
+# Short-Description: start and stop h2o HTTP Server
+# Description: H2O - the optimized HTTP/1, HTTP/2 server
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+if [ -f /etc/sysconfig/h2o ]; then
+    . /etc/sysconfig/h2o
+fi
+
+# Path to the server binary, and short-form for messages.
+h2o=/usr/sbin/h2o
+prog=h2o
+configfile=/etc/h2o/h2o.conf
+lockfile=${LOCKFILE-/var/lock/subsys/h2o}
+RETVAL=0
+options="-m daemon -c $configfile"
+
+pidfile=`sed -ne 's|pid-file:\s*\([-_./0-9a-zA-Z]\{1,\}\)|\1|p' $configfile`
+if [ -z "$pidfile" ]; then
+    echo $"pid-file must be defined in $configfile"
+    exit 1
+fi
+
+start() {
+    echo -n $"Starting $prog: "
+    daemon --pidfile=${pidfile} $h2o $options
+    RETVAL=$?
+    echo
+    [ $RETVAL = 0 ] && touch ${lockfile}
+    return $RETVAL
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    killproc -p ${pidfile} $h2o -TERM
+    RETVAL=$?
+    echo
+    [ $RETVAL = 0 ] && rm -f ${lockfile}
+}
+
+reload() {
+    echo -n $"Reloading $prog: "
+    if ! $h2o -t -c ${configfile} >&/dev/null; then
+        RETVAL=6
+        echo $"not reloading due to configuration syntax error"
+        failure $"not reloading $h2o due to configuration syntax error"
+    else
+        # Force LSB behaviour from killproc
+        LSB=1 killproc -p ${pidfile} $h2o -HUP
+        RETVAL=$?
+        if [ $RETVAL -eq 7 ]; then
+            failure $"h2o shutdown"
+        fi
+    fi
+    echo
+}
+
+configtest() {
+    $h2o -t -c ${configfile}
+}
+
+# See how we were called.
+case "$1" in
+  start)
+        start
+        ;;
+  stop)
+        stop
+        ;;
+  status)
+        status -p ${pidfile} $h2o
+        RETVAL=$?
+        ;;
+  restart)
+        stop
+        start
+        ;;
+  condrestart|try-restart)
+        if status -p ${pidfile} $h2o >&/dev/null; then
+            stop
+            start
+        fi
+        ;;
+  force-reload|reload)
+        reload
+        ;;
+  configtest)
+        configtest
+        RETVAL=$?
+        ;;
+  *)
+        echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|configtest}"
+        RETVAL=2
+esac
+
+exit $RETVAL
diff --git a/h2o.logrotate b/h2o.logrotate
new file mode 100644 (file)
index 0000000..6176485
--- /dev/null
@@ -0,0 +1,16 @@
+/var/log/h2o/error.log {
+    missingok
+    notifempty
+    delaycompress
+    copytruncate
+}
+
+/var/log/h2o/access.log {
+    missingok
+    notifempty
+    sharedscripts
+    delaycompress
+    postrotate
+        /bin/systemctl reload h2o.service > /dev/null 2>/dev/null || true
+    endscript
+}
diff --git a/h2o.service b/h2o.service
new file mode 100644 (file)
index 0000000..28e1295
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=H2O - the optimized HTTP/1, HTTP/2 server
+After=network.target remote-fs.target nss-lookup.target
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/h2o -m master -c /etc/h2o/h2o.conf
+ExecReload=/bin/kill -HUP ${MAINPID}
+ExecStop=/bin/kill -TERM ${MAINPID}
+PrivateTmp=true
+LimitNOFILE=infinity
+
+[Install]
+WantedBy=multi-user.target
index 27cd440917a7fb9b0fff50ae8376260ad2ebb07b..572f9ac11bd376df0dc2c8f8bf681d6363964c3d 100644 (file)
--- a/h2o.spec
+++ b/h2o.spec
@@ -7,11 +7,16 @@
 Summary:       H2O - an optimized HTTP server with support for HTTP/1.x and HTTP/2
 Name:          h2o
 Version:       2.2.2
-Release:       0.1
+Release:       0.2
 License:       MIT
 Group:         Networking/Daemons/HTTP
 Source0:       https://github.com/h2o/h2o/archive/v%{version}/%{name}-%{version}.tar.gz
 # Source0-md5: efc3a98cd21d3b91d66b2a99b1518255
+Source1:       index.html
+Source2:       %{name}.logrotate
+Source3:       %{name}.init
+Source4:       %{name}.service
+Source5:       %{name}.conf
 Patch0:                system-ca.patch
 URL:           https://h2o.examp1e.net/
 BuildRequires: cmake >= 2.8.11
@@ -81,9 +86,32 @@ rm -rf $RPM_BUILD_ROOT
 
 %{__rm} -r $RPM_BUILD_ROOT%{_docdir}/%{name}
 
+install -d $RPM_BUILD_ROOT{%{_sysconfdir}/%{name},/etc/{rc.d/init.d,logrotate.d},%{systemdunitdir},%{systemdtmpfilesdir},%{_localstatedir}/{log,run}/h2o}
+
+cp -p %{_sourcedir}/h2o.conf $RPM_BUILD_ROOT%{_sysconfdir}/h2o/h2o.conf
+cp -p %{_sourcedir}/h2o.service $RPM_BUILD_ROOT%{systemdunitdir}/h2o.service
+cp -p %{_sourcedir}/h2o.tmpfiles $RPM_BUILD_ROOT%{systemdtmpfilesdir}/h2o.conf
+install -p %{_sourcedir}/h2o.init $RPM_BUILD_ROOT/etc/rc.d/init.d/h2o
+cp -p %{_sourcedir}/h2o.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/h2o
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%post
+/sbin/chkconfig --add %{name}
+%service %{name} restart
+%systemd_post %{name}.service
+
+%preun
+if [ "$1" = "0" ]; then
+       %service -q %{name} stop
+       /sbin/chkconfig --del %{name}
+fi
+%systemd_preun %{name}.service
+
+%postun
+%systemd_reload
+
 %post  -n libh2o -p /sbin/ldconfig
 %postun        -n libh2o -p /sbin/ldconfig
 
@@ -94,6 +122,11 @@ rm -rf $RPM_BUILD_ROOT
 %defattr(644,root,root,755)
 %doc README.md Changes LICENSE
 %attr(755,root,root) %{_sbindir}/h2o
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/h2o.conf
+%config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/h2o
+%attr(754,root,root) /etc/rc.d/init.d/h2o
+%{systemdunitdir}/h2o.service
+%{systemdtmpfilesdir}/h2o.conf
 %dir %{_datadir}/%{name}
 %{_datadir}/%{name}/status
 %attr(755,root,root) %{_datadir}/%{name}/annotate-backtrace-symbols
diff --git a/h2o.tmpfiles b/h2o.tmpfiles
new file mode 100644 (file)
index 0000000..a558517
--- /dev/null
@@ -0,0 +1,2 @@
+#Type Path     Mode UID  GID    Age Argument
+d     /var/run/h2o  770 root nobody -   -
diff --git a/index.html b/index.html
new file mode 100644 (file)
index 0000000..2d8ed62
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Welcome to H2O</title>
+  </head>
+  <body>
+    <p>Welcome to H2O - an optimized HTTP server</p>
+    <p>It works!</p>
+  </body>
+</html>
This page took 0.073676 seconds and 4 git commands to generate.