changeset 253: |
ff7589f4656d |
parent: |
80e639d0b203
|
child: |
e2b8d0be0d24 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Wed, 12 Jun 2024 13:56:58 -0400 |
permissions: |
-rwxr-xr-x |
description: |
add caddy-webdav and xcaddy |
19 export INFRA_HOST_CONFIG=$(cat
/proc/sys/kernel/hostname
).sxp
20 rm
-f
$INFRA_HOST_CONFIG 22 local _mem_total="$RETVAL" 25 get_architecture
|| return 1 27 assert_nz
"$_arch" "arch" 28 _write
";;; $INFRA_HOST_CONFIG -*- mode:skel -*-" 29 _write
":arch \"$_arch\"" 31 local _kernel_version="$RETVAL" 32 _write
":kernel \"$_kernel_version\"" 34 local _num_cpus="$RETVAL" 35 _write
":cpus $_num_cpus" 36 _write
":mem $_mem_total" 51 say
"$1=$(eval echo "\$$1" 2>
/dev/null
)" 55 say
"$1" >>
$INFRA_HOST_CONFIG 64 if [ -z
"$1" ]; then err
"assert_nz $2"; fi 68 command -v
"$1" >
/dev/null
2>
&1 72 if !
check_cmd
"$1"; then 73 err
"need '$1' (command not found)" 78 if !
"$@"; then err
"command failed: $*"; fi 82 # Check for /proc by looking for the /proc/self/exe link 83 # This is only run on Linux 84 if !
test -L
/proc/self/exe
; then 85 err
"fatal: Unable to find /proc/self/exe. Is /proc mounted? Installation cannot proceed without /proc." 90 # Architecture detection without dependencies beyond coreutils. 91 # ELF files start out "\x7fELF", and the following byte is 94 # The printf builtin on some shells like dash only supports octal 95 # escape sequences, so we use those. 96 local _current_exe_head
97 _current_exe_head=$(head
-c
5 /proc/self/exe
) 98 if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then 100 elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then 103 err
"unknown platform bitness" 107 is_host_amd64_elf
() { 108 # ELF e_machine detection without dependencies beyond coreutils. 109 # Two-byte field at offset 0x12 indicates the CPU, 110 # but we're interested in it being 0x3E to indicate amd64, or not that. 111 local _current_exe_machine
112 _current_exe_machine=$(head
-c
19 /proc/self/exe
| tail
-c
1) 113 [ "$_current_exe_machine" = "$(printf '\076')" ] 121 # detect endianness without od/hexdump, like get_bitness() does. 122 local _current_exe_endianness
123 _current_exe_endianness="$(head
-c
6 /proc/self/exe
| tail
-c
1)" 124 if [ "$_current_exe_endianness" = "$(printf '\001')" ]; then 125 echo "${cputype}${suffix_el}" 126 elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then 127 echo "${cputype}${suffix_eb}" 129 err
"unknown platform endianness" 134 local _ostype
_cputype
_bitness
_arch
_clibtype
135 _ostype="$(uname
-s
)" 136 _cputype="$(uname
-m
)" 139 if [ "$_ostype" = Linux
]; then 140 if [ "$(uname
-o
)" = Android
]; then 143 if ldd
--version
2>
&1 | grep
-q
'musl'; then 148 if [ "$_ostype" = Darwin
] && [ "$_cputype" = i386
]; then 149 # Darwin `uname -m` lies 150 if sysctl
hw.optional.x86_64
| grep
-q
': 1'; then 155 if [ "$_ostype" = SunOS
]; then 156 # Both Solaris and illumos presently announce as "SunOS" in "uname -s" 157 # so use "uname -o" to disambiguate. We use the full path to the 158 # system uname in case the user has coreutils uname first in PATH, 159 # which has historically sometimes printed the wrong value here. 160 if [ "$(/usr/bin/uname
-o
)" = illumos
]; then 164 # illumos systems have multi-arch userlands, and "uname -m" reports the 165 # machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86 166 # systems. Check for the native (widest) instruction set on the 168 if [ "$_cputype" = i86pc
]; then 169 _cputype="$(isainfo
-n
)" 176 _ostype=linux-android
181 _ostype=unknown-linux-
$_clibtype 182 _bitness=$(get_bitness
) 186 _ostype=unknown-freebsd
190 _ostype=unknown-netbsd
194 _ostype=unknown-dragonfly
202 _ostype=unknown-illumos
205 MINGW*
| MSYS*
| CYGWIN*
| Windows_NT
) 206 _ostype=pc-windows-gnu
210 err
"unrecognized OS type: $_ostype" 217 i386
| i486
| i686
| i786
| x86
) 223 if [ "$_ostype" = "linux-android" ]; then 224 _ostype=linux-androideabi
230 if [ "$_ostype" = "linux-android" ]; then 231 _ostype=linux-androideabi
233 _ostype="${_ostype}eabihf" 239 if [ "$_ostype" = "linux-android" ]; then 240 _ostype=linux-androideabi
242 _ostype="${_ostype}eabihf" 250 x86_64
| x86-64
| x64
| amd64
) 255 _cputype=$(get_endianness
mips
'' el
) 259 if [ "$_bitness" -eq
64 ]; then 260 # only n64 ABI is supported for now 261 _ostype="${_ostype}abi64" 262 _cputype=$(get_endianness
mips64
'' el
) 288 err
"unknown CPU type: $_cputype" 292 # Detect 64-bit linux with 32-bit userland 293 if [ "${_ostype}" = unknown-linux-gnu
] && [ "${_bitness}" -eq
32 ]; then 296 if [ -n
"${CPUTYPE:-}" ]; then 299 # 32-bit executable for amd64 = x32 300 if is_host_amd64_elf
; then { 301 echo "This host is running an x32 userland; as it stands, x32 support is poor," 1>
&2 302 echo "and there isn't a native toolchain -- you will have to install" 1>
&2 303 echo "multiarch compatibility with i686 and/or amd64, then select one" 1>
&2 304 echo "by re-running this script with the CPUTYPE environment variable" 1>
&2 305 echo "set to i686 or x86_64, respectively." 1>
&2 313 _cputype=$(get_endianness
mips
'' el
) 320 if [ "$_ostype" = "linux-android" ]; then 321 _ostype=linux-androideabi
323 _ostype="${_ostype}eabihf" 327 err
"riscv64 with 32-bit userland unsupported" 332 if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7
]; then 333 if ensure
grep
'^Features' /proc/cpuinfo
| grep
-q
-v
neon
; then 334 # At least one processor does not have NEON. 339 _arch="${_cputype}-${_ostype}" 346 _mem_total=$(awk
'/MemTotal/ {print $2}' /proc/meminfo
) 352 local _mem_total="$RETVAL" 353 local _mem_min=8388608 # 8Gb in kB 354 if [ "$_mem_total" -lt
"$_mem_min" ]; then 355 err
"not enough memory: $_mem_total < $_mem_min"; 361 _disk_free=$(df
.
| tail
-n1
| awk
'{print $4}') 362 RETVAL="${_disk_free}" 367 local _disk_free="$RETVAL" 368 local _disk_min=33554432 # in bytes 369 if [ "$_disk_free" -lt
"$_disk_min" ]; then 370 err
"not enough disk space: $_disk_free < $_disk_min" 375 local _kernel_version
376 _kernel_version=$(uname
-r
) 377 RETVAL="$_kernel_version" 381 if !
lsmod
| grep
-wq
"$1"; then 382 err
"kernel module $1 isn't loaded" 388 _num_cpus=$(grep
-c
'^processor' /proc/cpuinfo
2>/dev/null
) 390 # sysctl -n hw.ncpu # nproc --all 395 local _num_cpus="$RETVAL" 397 if [ "$_num_cpus" -lt
"$_min_cpus" ]; then 398 err
"not enough cpu threads ($_num_cpus < $_min_cpus)" 408 say_var
INSTALL_PREFIX