commit 81a622221bd20b86fa5a2844ac5781f138628e1d6e5f7738be03da20d4ba1a92 Author: Marguerite Su Date: Wed May 5 09:08:17 2021 +0000 Accepting request 889343 from home:avicenzi Add Caddy OBS-URL: https://build.opensuse.org/request/show/889343 OBS-URL: https://build.opensuse.org/package/show/server:http/caddy?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..83d2c36 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,25 @@ +# The Caddyfile is an easy way to configure your Caddy web server. +# +# Unless the file starts with a global options block, the first +# uncommented line is always the address of your site. +# +# To use your own domain name (with automatic HTTPS), first make +# sure your domain's A/AAAA DNS records are properly pointed to +# this machine's public IP, then replace the line below with your +# domain name. +:80 + +# Set this path to your site's directory. +root * /usr/share/caddy + +# Enable the static file server. +file_server + +# Another common task is to set up a reverse proxy: +# reverse_proxy localhost:8080 + +# Or serve a PHP site through php-fpm: +# php_fastcgi localhost:9000 + +# Refer to the Caddy docs for more information: +# https://caddyserver.com/docs/caddyfile diff --git a/_caddy b/_caddy new file mode 100644 index 0000000..2cd815d --- /dev/null +++ b/_caddy @@ -0,0 +1,166 @@ +#compdef caddy + +function _caddy { + local _line + + _arguments -C \ + "1: :(adapt build-info environ file-server fmt hash-password help list-modules reload reverse-proxy run start stop trust untrust validate version)" \ + "*::arg:->args" + + case $line[1] in + adapt) + __caddy_adapt + ;; + build-info) + __caddy_build-info + ;; + environ) + __caddy_environ + ;; + file-server) + __caddy_file-server + ;; + fmt) + __caddy_fmt + ;; + hash-password) + __caddy_hash-password + ;; + help) + __caddy_help + ;; + list-modules) + __caddy_list-modules + ;; + reload) + __caddy_reload + ;; + reverse-proxy) + __caddy_reverse-proxy + ;; + run) + __caddy_run + ;; + start) + __caddy_start + ;; + stop) + __caddy_stop + ;; + trust) + __caddy_trust + ;; + untrust) + __caddy_untrust + ;; + validate) + __caddy_validate + ;; + version) + __caddy_version + ;; + esac +} + +function __caddy_adapt { + _arguments \ + "--pretty: :" \ + "--validate: :" \ + "--adapter: :_files" \ + "--config: :_files" \ + +} +function __caddy_build-info { + +} +function __caddy_environ { + +} +function __caddy_file-server { + _arguments \ + "--browse: :" \ + "--templates: :" \ + "--domain: :_files" \ + "--listen: :_files" \ + "--root: :_dirs" \ + +} +function __caddy_fmt { + _arguments \ + "--overwrite: :" \ + +} +function __caddy_hash-password { + _arguments \ + "--algorithm: :_files" \ + "--plaintext: :_files" \ + "--salt: :_files" \ + +} +function __caddy_help { + +} +function __caddy_list-modules { + _arguments \ + "--versions: :" \ + +} +function __caddy_reload { + _arguments \ + "--adapter: :_files" \ + "--config: :_files" \ + "--address: :_files" \ + +} +function __caddy_reverse-proxy { + _arguments \ + "--change-host-header: :" \ + "--from: :_files" \ + "--to: :_files" \ + +} +function __caddy_run { + _arguments \ + "--environ: :" \ + "--resume: :" \ + "--watch: :" \ + "--adapter: :_files" \ + "--config: :_files" \ + "--pingback: :_files" \ + "--pidfile: :_files" \ + +} +function __caddy_start { + _arguments \ + "--watch: :" \ + "--adapter: :_files" \ + "--config: :_files" \ + "--pidfile: :_files" \ + +} +function __caddy_stop { + _arguments \ + "--address: :_files" \ + +} +function __caddy_trust { + +} +function __caddy_untrust { + _arguments \ + "--ca: :_files" \ + "--cert: :_files" \ + +} +function __caddy_validate { + _arguments \ + "--config: :_files" \ + "--adapter: :_files" \ + +} +function __caddy_version { + +} + +_caddy + diff --git a/_service b/_service new file mode 100644 index 0000000..bb99e71 --- /dev/null +++ b/_service @@ -0,0 +1,20 @@ + + + https://github.com/caddyserver/caddy.git + git + caddy + @PARENT_TAG@ + v(.*) + v2.3.0 + enable + + + + + *.tar + gz + + + + + diff --git a/_servicedata b/_servicedata new file mode 100644 index 0000000..0884b6c --- /dev/null +++ b/_servicedata @@ -0,0 +1,4 @@ + + + https://github.com/caddyserver/caddy.git + 1b453dd4fbea2f3a54362fb4c2115bab85cad1b7 \ No newline at end of file diff --git a/bash-completion b/bash-completion new file mode 100644 index 0000000..82eea79 --- /dev/null +++ b/bash-completion @@ -0,0 +1,1210 @@ +# caddy completion -*- shell-script -*- + +# helper method +declare -f _contains_element > /dev/null || _contains_element() { + local e match="$1" + shift + for e; do [[ "$e" == "$match" ]] && return 0; done + return 1 +} + +_caddy_completions() +{ + # get current word, words array, current word index, and previous word, ignoring ":" as a wordbreak + local cur cword words + _get_comp_words_by_ref -n ":" cur words cword prev + + # complete subcommands list + if [ "$cword" -eq "1" ] && [ "adapt build-info environ file-server fmt hash-password help list-modules reload reverse-proxy run start stop trust untrust validate version" != "" ]; then + COMPREPLY=($(compgen -W "adapt build-info environ file-server fmt hash-password help list-modules reload reverse-proxy run start stop trust untrust validate version" -- "$cur")) + __ltrim_colon_completions "$cur" + return + fi + + local subcommand="${words[1]}" + + local args used_flags used_args index + + # register completions for each subcommand + if [ "${subcommand}" == "adapt" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--pretty" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + if [ "${args[0]}" == "--validate" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--adapter" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--config" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--adapter" ]]; then + COMPREPLY=() + if command -v grep > /dev/null && command -v sed > /dev/null && command -v tr > /dev/null; then + COMPREPLY=($(compgen -W "$(caddy list-modules | grep adapters | sed s/caddy.adapters.// | tr ' +' ' ')" -- "$cur")) + fi + return + fi + if [[ "$prev" == "--config" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--pretty" "${used_flags[@]}"; then + completion+=("--pretty") + fi + if ! _contains_element "--validate" "${used_flags[@]}"; then + completion+=("--validate") + fi + if ! _contains_element "--adapter" "${used_flags[@]}"; then + completion+=("--adapter") + fi + if ! _contains_element "--config" "${used_flags[@]}"; then + completion+=("--config") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "build-info" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "environ" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "file-server" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--browse" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + if [ "${args[0]}" == "--templates" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--domain" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--listen" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--root" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--domain" ]]; then + COMPREPLY=() + return + fi + if [[ "$prev" == "--listen" ]]; then + COMPREPLY=() + return + fi + if [[ "$prev" == "--root" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -d -- "$cur")) + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--browse" "${used_flags[@]}"; then + completion+=("--browse") + fi + if ! _contains_element "--templates" "${used_flags[@]}"; then + completion+=("--templates") + fi + if ! _contains_element "--domain" "${used_flags[@]}"; then + completion+=("--domain") + fi + if ! _contains_element "--listen" "${used_flags[@]}"; then + completion+=("--listen") + fi + if ! _contains_element "--root" "${used_flags[@]}"; then + completion+=("--root") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "fmt" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--overwrite" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--overwrite" "${used_flags[@]}"; then + completion+=("--overwrite") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + if [[ "${#used_args[@]}" -eq "0" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + + return + fi + if [ "${subcommand}" == "hash-password" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + if [ "${args[0]}" == "--algorithm" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--plaintext" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--salt" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--algorithm" ]]; then + COMPREPLY=() + return + fi + if [[ "$prev" == "--plaintext" ]]; then + COMPREPLY=() + return + fi + if [[ "$prev" == "--salt" ]]; then + COMPREPLY=() + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--algorithm" "${used_flags[@]}"; then + completion+=("--algorithm") + fi + if ! _contains_element "--plaintext" "${used_flags[@]}"; then + completion+=("--plaintext") + fi + if ! _contains_element "--salt" "${used_flags[@]}"; then + completion+=("--salt") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "help" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + if [[ "${#used_args[@]}" -eq "0" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -W "adapt build-info environ file-server fmt hash-password help list-modules reload reverse-proxy run stop trust untrust validate" -- "$cur")) + return + fi + + return + fi + if [ "${subcommand}" == "list-modules" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--versions" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--versions" "${used_flags[@]}"; then + completion+=("--versions") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "reload" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + if [ "${args[0]}" == "--adapter" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--config" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--address" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--adapter" ]]; then + COMPREPLY=() + if command -v grep > /dev/null && command -v sed > /dev/null && command -v tr > /dev/null; then + COMPREPLY=($(compgen -W "$(caddy list-modules | grep adapters | sed s/caddy.adapters.// | tr ' +' ' ')" -- "$cur")) + fi + return + fi + if [[ "$prev" == "--config" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + if [[ "$prev" == "--address" ]]; then + COMPREPLY=() + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--adapter" "${used_flags[@]}"; then + completion+=("--adapter") + fi + if ! _contains_element "--config" "${used_flags[@]}"; then + completion+=("--config") + fi + if ! _contains_element "--address" "${used_flags[@]}"; then + completion+=("--address") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "reverse-proxy" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--change-host-header" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--from" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--to" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--from" ]]; then + COMPREPLY=() + return + fi + if [[ "$prev" == "--to" ]]; then + COMPREPLY=() + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--change-host-header" "${used_flags[@]}"; then + completion+=("--change-host-header") + fi + if ! _contains_element "--from" "${used_flags[@]}"; then + completion+=("--from") + fi + if ! _contains_element "--to" "${used_flags[@]}"; then + completion+=("--to") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "run" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--environ" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + if [ "${args[0]}" == "--resume" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + if [ "${args[0]}" == "--watch" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--adapter" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--config" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--pingback" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--pidfile" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--adapter" ]]; then + COMPREPLY=() + if command -v grep > /dev/null && command -v sed > /dev/null && command -v tr > /dev/null; then + COMPREPLY=($(compgen -W "$(caddy list-modules | grep adapters | sed s/caddy.adapters.// | tr ' +' ' ')" -- "$cur")) + fi + return + fi + if [[ "$prev" == "--config" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + if [[ "$prev" == "--pingback" ]]; then + COMPREPLY=() + return + fi + if [[ "$prev" == "--pidfile" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--environ" "${used_flags[@]}"; then + completion+=("--environ") + fi + if ! _contains_element "--resume" "${used_flags[@]}"; then + completion+=("--resume") + fi + if ! _contains_element "--watch" "${used_flags[@]}"; then + completion+=("--watch") + fi + if ! _contains_element "--adapter" "${used_flags[@]}"; then + completion+=("--adapter") + fi + if ! _contains_element "--config" "${used_flags[@]}"; then + completion+=("--config") + fi + if ! _contains_element "--pingback" "${used_flags[@]}"; then + completion+=("--pingback") + fi + if ! _contains_element "--pidfile" "${used_flags[@]}"; then + completion+=("--pidfile") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "start" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--watch" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + if [ "${args[0]}" == "--adapter" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--config" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--pidfile" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--adapter" ]]; then + COMPREPLY=() + if command -v grep > /dev/null && command -v sed > /dev/null && command -v tr > /dev/null; then + COMPREPLY=($(compgen -W "$(caddy list-modules | grep adapters | sed s/caddy.adapters.// | tr ' +' ' ')" -- "$cur")) + fi + return + fi + if [[ "$prev" == "--config" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + if [[ "$prev" == "--pidfile" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--watch" "${used_flags[@]}"; then + completion+=("--watch") + fi + if ! _contains_element "--adapter" "${used_flags[@]}"; then + completion+=("--adapter") + fi + if ! _contains_element "--config" "${used_flags[@]}"; then + completion+=("--config") + fi + if ! _contains_element "--pidfile" "${used_flags[@]}"; then + completion+=("--pidfile") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "stop" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + if [ "${args[0]}" == "--address" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--address" ]]; then + COMPREPLY=() + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--address" "${used_flags[@]}"; then + completion+=("--address") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "trust" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "untrust" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + if [ "${args[0]}" == "--ca" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--cert" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--ca" ]]; then + COMPREPLY=() + return + fi + if [[ "$prev" == "--cert" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--ca" "${used_flags[@]}"; then + completion+=("--ca") + fi + if ! _contains_element "--cert" "${used_flags[@]}"; then + completion+=("--cert") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "validate" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + if [ "${args[0]}" == "--config" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + if [ "${args[0]}" == "--adapter" ]; then + used_flags+=("${args[0]}") + args=("${args[@]:2}") + index=$((index+2)) + continue + fi + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + if [[ "$prev" == "--config" ]]; then + COMPREPLY=() + COMPREPLY=($(compgen -f -- "$cur")) + return + fi + if [[ "$prev" == "--adapter" ]]; then + COMPREPLY=() + if command -v grep > /dev/null && command -v sed > /dev/null && command -v tr > /dev/null; then + COMPREPLY=($(compgen -W "$(caddy list-modules | grep adapters | sed s/caddy.adapters.// | tr ' +' ' ')" -- "$cur")) + fi + return + fi + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + if ! _contains_element "--config" "${used_flags[@]}"; then + completion+=("--config") + fi + if ! _contains_element "--adapter" "${used_flags[@]}"; then + completion+=("--adapter") + fi + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi + if [ "${subcommand}" == "version" ]; then + local args_shift=2 + # get the list of already used flags and args, ignoring the current word + args=("${words[@]:args_shift}") # args without command and subcommand + used_flags=() + used_args=() + index=0 + + while [ "${#args[@]}" -gt 0 ]; do + if [ "${index}" -eq "$((cword-args_shift))" ]; then + # ignore current word + args=("${args[@]:1}") + index=$((index+1)) + continue + fi + + + + if [[ "${args[0]}" != "-"* ]]; then + used_args+=("${args[0]}") + fi + args=("${args[@]:1}") + index=$((index+1)) + done + + + if [[ $cur == -* ]]; then + # flags + completion=() + + if [[ $cur != --* ]]; then + true + fi + + + COMPREPLY=($(compgen -W "${completion[*]}" -- "$cur")) + return + fi + + + return + fi +} + +# register completion +complete -F _caddy_completions caddy + diff --git a/caddy-2.3.0.tar.gz b/caddy-2.3.0.tar.gz new file mode 100644 index 0000000..b852017 --- /dev/null +++ b/caddy-2.3.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8fceff25a386d14954f8c0e6978c0a46f6db8cb115a34584a62a1e629aa52a0 +size 29870746 diff --git a/caddy.changes b/caddy.changes new file mode 100644 index 0000000..81a6bbc --- /dev/null +++ b/caddy.changes @@ -0,0 +1,4 @@ +------------------------------------------------------------------- +Wed Apr 28 15:47:43 UTC 2021 - Alexandre Vicenzi + +- Create Caddy package diff --git a/caddy.service b/caddy.service new file mode 100644 index 0000000..18d47b5 --- /dev/null +++ b/caddy.service @@ -0,0 +1,20 @@ +[Unit] +Description=Caddy +Documentation=https://caddyserver.com/docs/ +After=network.target network-online.target +Requires=network-online.target + +[Service] +User=caddy +Group=caddy +ExecStart=/usr/bin/caddy run --resume --environ --config /etc/caddy/Caddyfile +ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile +TimeoutStopSec=5s +LimitNOFILE=1048576 +LimitNPROC=512 +PrivateTmp=true +ProtectSystem=full +AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target diff --git a/caddy.spec b/caddy.spec new file mode 100644 index 0000000..74f8657 --- /dev/null +++ b/caddy.spec @@ -0,0 +1,118 @@ +# +# spec file for package caddy +# +# Copyright (c) 2021 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + +%define project github.com/caddyserver/caddy + +Name: caddy +Version: 2.3.0 +Release: 0 +Summary: Fast, multi-platform web server with automatic HTTPS +License: Apache-2.0 +Group: Productivity/Networking/Web/Proxy +URL: https://caddyserver.com/ +Source0: %{name}-%{version}.tar.gz +Source1: vendor.tar.gz +Source2: Caddyfile +Source3: caddy.service +Source4: index.html +Source5: bash-completion +Source6: _caddy +BuildRequires: golang-packaging +BuildRequires: golang(API) >= 1.15 +BuildRequires: systemd-rpm-macros +%{?systemd_requires} +%{go_provides} +# Make sure that the binary is not getting stripped. +%{go_nostrip} + +%description +Caddy is a powerful, extensible platform to serve your sites, services, and +apps, written in Go. + +It operates primarily at L4 (transport layer) and L7 (application layer) of +the OSI model, though it has the ability to work with other layers. + +%prep +%setup -q + +%build +%{goprep} %{project} + +# tarball causes "inconsistent vendoring" +tar -xf vendor.tar.gz +rm -rf vendor.tar.gz + +CGO_ENABLED=0 + +go build -v -buildmode=pie -mod=vendor -ldflags "-s -w" -o caddy cmd/caddy/main.go + +%install +install -d %{buildroot}/%{_sbindir} +install -D -p -m 0755 %{name} %{buildroot}%{_bindir}/%{name} + +# configuration +install -D -p -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}/Caddyfile + +# service +install -D -p -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service +ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name} + +# data directory +install -d -m 0750 %{buildroot}%{_sharedstatedir}/%{name} + +# welcome page +install -D -p -m 0644 %{SOURCE4} %{buildroot}%{_datadir}/%{name}/index.html + +# bash completion +install -D -p -m 0644 %{SOURCE5} %{buildroot}%{_datadir}/bash-completion/completions/%{name} +install -D -p -m 0644 %{SOURCE6} %{buildroot}%{_datadir}/zsh/site-functions/_%{name} + +%pre +getent group %{name} >/dev/null || %{_sbindir}/groupadd -r %{name} +getent passwd %{name} >/dev/null || %{_sbindir}/useradd -r -g %{name} -d %{_localstatedir}/lib/%{name} -s /bin/false -c "Caddy web server" %{name} +%service_add_pre %{name}.service + +%post +%service_add_post %{name}.service +%{fillup_only -n %{name}} + +%preun +%service_del_preun %{name}.service + +%postun +%service_del_postun %{name}.service + +%files +%license LICENSE +%doc AUTHORS README.md +%{_bindir}/%{name} +%{_datadir}/%{name} + +%{_unitdir}/%{name}.service +%{_sbindir}/rc%{name} + +%dir %{_sysconfdir}/%{name} +%config(noreplace) %{_sysconfdir}/%{name}/Caddyfile +%attr(0750,%{name},%{name}) %dir %{_sharedstatedir}/%{name} +# filesystem owns all the parent directories here +%{_datadir}/bash-completion/completions/%{name} +# own parent directories in case zsh is not installed +%dir %{_datadir}/zsh +%dir %{_datadir}/zsh/site-functions +%{_datadir}/zsh/site-functions/_%{name} + +%changelog diff --git a/index.html b/index.html new file mode 100644 index 0000000..78b7777 --- /dev/null +++ b/index.html @@ -0,0 +1,269 @@ + + + + Caddy works! + + + + + + +
+
+
+
+ + +

+ Congratulations! + おめでとう! + Felicidades! + 恭喜! + बधाई हो! + Поздравляю!
 + 🎊 +

+ +

+ Your web server is working. Now make it work for you. 💪 +

+

+ Caddy is ready to serve your site over HTTPS: +

+
    +
  1. Point your domain's A/AAAA DNS records at this machine.
  2. +
  3. Upload your site's files to /var/www/html. +
  4. + Edit your Caddyfile at /etc/caddy/Caddyfile: +
      +
    1. Replace :80 with your domain name
    2. +
    3. Change the site root to /var/www/html
    4. +
    +
  5. +
  6. Reload the configuration: systemctl reload caddy
  7. +
  8. Visit your site!
  9. +
+

If that worked 🥳

+

+ Awesome! You won't have to look at this slanted page anymore. +

+

+ Remember, Caddy can do a lot more than serve static files. It's also a powerful reverse proxy and application platform. You can use the Caddyfile to enable any other features you need. Or you could use Caddy's API to configure it programmatically. +

+

+ Everything you need to know is either in the 📖 Caddy documentation or the manual for your OS/platform. Have fun! +

+ +

If that didn't work 😶

+

+ It's okay, you can fix it! First check the following things: +

+
    +
  • Service status: systemctl status caddy
  • +
  • Logs: journalctl --no-pager -u caddy
  • +
  • Are your site's files readable by the caddy user and group? ls -la /var/www/html
  • +
  • Is the caddy home directory writeable? ls -la /var/lib/caddy
  • +
  • Ensure your domain's A and/or AAAA records point to your machine's public IP address: dig example.com
  • +
  • Are your ports 80 and 443 externally reachable, and is Caddy able to bind to them? Check your firewalls, port forwarding, and other network configuration.
  • +
+

+ WAIT! Before trying again, switch to Let's Encrypt's staging environment to avoid being accidentally rate limited. Once you get everything else working, it's safe to switch back. +

+

+ Depending on your DNS provider, it may take a while for the DNS records to propagate. Even when everything is configured properly, automated challenges to obtain TLS certificates usually take several seconds, but may take up to several minutes or hours. +

+ If you still need help, we have a great community! First try a search, and if your question is original, go ahead and ask it! Remember to pay it forward and help others too. 😁 +

+

+ Visit Caddy on: + GitHub + or + Twitter + or + Our Forum +

+
+
+ + + + + diff --git a/vendor.tar.gz b/vendor.tar.gz new file mode 100644 index 0000000..faa96ac --- /dev/null +++ b/vendor.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35e30c83ce2cb4796e340b0b9b84865c95c96f3ac639c869332eadf0cbab4b36 +size 6622214