mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-10 07:57:59 -05:00
86 lines
4.0 KiB
Ruby
86 lines
4.0 KiB
Ruby
require 'package'
|
|
|
|
class Nginx < Package
|
|
description 'nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server, originally written by Igor Sysoev.'
|
|
homepage 'http://nginx.org/'
|
|
version '1.17.4'
|
|
source_url 'https://nginx.org/download/nginx-1.17.4.tar.gz'
|
|
source_sha256 '62854b365e66670ef4f1f8cc79124f914551444da974207cd5fe22d85710e555'
|
|
|
|
binary_url ({
|
|
aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/nginx-1.17.4-chromeos-armv7l.tar.xz',
|
|
armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/nginx-1.17.4-chromeos-armv7l.tar.xz',
|
|
i686: 'https://dl.bintray.com/chromebrew/chromebrew/nginx-1.17.4-chromeos-i686.tar.xz',
|
|
x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/nginx-1.17.4-chromeos-x86_64.tar.xz',
|
|
})
|
|
binary_sha256 ({
|
|
aarch64: 'f67f978ee52a403fb628c0d4128c01a0b556974d4a573afd1ae3f3228c5e3f72',
|
|
armv7l: 'f67f978ee52a403fb628c0d4128c01a0b556974d4a573afd1ae3f3228c5e3f72',
|
|
i686: '04adfd5c84292dfeb788a982d970373b786ec511710083bb0f1611bcb359a630',
|
|
x86_64: '25c755241869d55397734f97bc1ee96ad36fd028315f5ffd151eabda7c66de5e',
|
|
})
|
|
|
|
depends_on 'pcre'
|
|
|
|
def self.build
|
|
system './configure',
|
|
"--prefix=#{CREW_PREFIX}/share/nginx"
|
|
system 'make'
|
|
end
|
|
|
|
def self.install
|
|
system 'make', "DESTDIR=#{CREW_DEST_DIR}", 'install'
|
|
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/bin"
|
|
FileUtils.cd("#{CREW_DEST_PREFIX}/bin") do
|
|
system "ln -s #{CREW_PREFIX}/share/nginx/sbin/nginx nginx"
|
|
system "echo '#!/bin/bash' > startnginx"
|
|
system "echo 'NGINX=\$(ps ax | grep \"nginx: master process\" | grep -v grep | xargs | cut -d\" \" -f1 2> /dev/null)' >> startnginx"
|
|
system "echo 'if [ -z \"\$NGINX\" ]; then' >> startnginx"
|
|
system "echo ' sudo nginx' >> startnginx"
|
|
system "echo 'fi' >> startnginx"
|
|
system "echo 'NGINX=\$(ps ax | grep \"nginx: master process\" | grep -v grep | xargs | cut -d\" \" -f1 2> /dev/null)' >> startnginx"
|
|
system "echo 'if [ ! -z \"\$NGINX\" ]; then' >> startnginx"
|
|
system "echo ' echo \"nginx process \$NGINX is running\"' >> startnginx"
|
|
system "echo 'else' >> startnginx"
|
|
system "echo ' echo \"nginx failed to start\"' >> startnginx"
|
|
system "echo ' exit 1' >> startnginx"
|
|
system "echo 'fi' >> startnginx"
|
|
system "echo '#!/bin/bash' > stopnginx"
|
|
system "echo 'NGINX=\$(ps ax | grep \"nginx: master process\" | grep -v grep | xargs | cut -d\" \" -f1 2> /dev/null)' >> stopnginx"
|
|
system "echo 'if [ ! -z \"\$NGINX\" ]; then' >> stopnginx"
|
|
system "echo ' sudo nginx -s quit' >> stopnginx"
|
|
system "echo 'fi' >> stopnginx"
|
|
system "echo 'NGINX=\$(ps ax | grep \"nginx: master process\" | grep -v grep | xargs | cut -d\" \" -f1 2> /dev/null)' >> stopnginx"
|
|
system "echo 'if [ -z \"\$NGINX\" ]; then' >> stopnginx"
|
|
system "echo ' echo \"nginx process stopped\"' >> stopnginx"
|
|
system "echo 'else' >> stopnginx"
|
|
system "echo ' echo \"nginx process \$NGINX is running\"' >> stopnginx"
|
|
system "echo ' exit 1' >> stopnginx"
|
|
system "echo 'fi' >> stopnginx"
|
|
system "chmod +x st*nginx"
|
|
end
|
|
end
|
|
|
|
def self.postinstall
|
|
puts
|
|
puts "All things NGINX are in #{CREW_PREFIX}/share/nginx.".lightblue
|
|
puts
|
|
puts "Pages are stored in #{CREW_PREFIX}/share/nginx/html.".lightblue
|
|
puts
|
|
puts "To start/stop nginx, execute the following:".lightblue
|
|
puts "startnginx - starts nginx".lightblue
|
|
puts "stopnginx - stops nginx".lightblue
|
|
puts
|
|
puts "To start nginx on login, execute the following:".lightblue
|
|
puts "echo 'if [ -f #{CREW_PREFIX}/bin/startnginx ]; then' >> ~/.bashrc".lightblue
|
|
puts "echo ' #{CREW_PREFIX}/bin/startnginx' >> ~/.bashrc".lightblue
|
|
puts "echo 'fi' >> ~/.bashrc".lightblue
|
|
puts "source ~/.bashrc".lightblue
|
|
puts
|
|
puts "To completely remove nginx, perform the following:".lightblue
|
|
puts "crew remove nginx".lightblue
|
|
puts "sudo rm -rf #{CREW_PREFIX}/share/nginx".lightblue
|
|
puts
|
|
end
|
|
end
|