fixes, improve host-info-update master
authorIan Kelling <ian@iankelling.org>
Sat, 27 Apr 2024 20:55:54 +0000 (16:55 -0400)
committerIan Kelling <ian@iankelling.org>
Sat, 27 Apr 2024 20:55:54 +0000 (16:55 -0400)
brc
brc2
distro-end
nextcloud-setup

diff --git a/brc b/brc
index 4a6f67274a44f98b5be8b9b88b5e11fbf1327d6b..2fbce5534d3f8b116fba0573d6c37742d7ca1e40 100644 (file)
--- a/brc
+++ b/brc
@@ -1672,9 +1672,9 @@ grr() { # grep recursive
   # Don't return 1 on nonmatch because this is meant to be
   # interactive, not in a conditional.
   if [[ ${#@} == 1 ]]; then
   # Don't return 1 on nonmatch because this is meant to be
   # interactive, not in a conditional.
   if [[ ${#@} == 1 ]]; then
-    grep -E --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" . || [[ $? == 1 ]]
+    grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" . || [[ $? == 1 ]]
   else
   else
-    grep -E --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" || [[ $? == 1 ]]
+    grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" || [[ $? == 1 ]]
   fi
 }
 ccomp grep gr grr
   fi
 }
 ccomp grep gr grr
diff --git a/brc2 b/brc2
index 45249e6a8f533e812f6a15d394058503c14ad793..6988b81fd4a062c8d78657894b35cbfd4f5100a6 100644 (file)
--- a/brc2
+++ b/brc2
@@ -2574,10 +2574,13 @@ ilog-local() {
   done
 }
 ilog() {
   done
 }
 ilog() {
-  local chan
+  local chan tmpf
+  tmpf=$(mktemp)
   chan="${1:-#fsfsys}"
   # use * instead of -r since that does sorted order
   chan="${1:-#fsfsys}"
   # use * instead of -r since that does sorted order
-  sl root@iankelling.org ilog-local "$chan" | less +G
+  sl root@li.b8.nz ilog-local "$chan" > $tmpf
+  less +G $tmpf
+  rm -f $tmpf
 }
 
 o() {
 }
 
 o() {
@@ -2644,7 +2647,7 @@ host-info-all() {
 # wrt-setup
 host-info-update() {
 
 # wrt-setup
 host-info-update() {
 
-  local -A vpn_ips host_ips host_macs nonvpn_ips
+  local -A vpn_ips host_ips host_macs nonvpn_ips all_ips
   local -a root_hosts nonroot_hosts
 
   # the hosts with no mac
   local -a root_hosts nonroot_hosts
 
   # the hosts with no mac
@@ -2656,37 +2659,95 @@ host-info-update() {
 
   while read -r ip host mac opts; do
     if [[ $ip == *#*  || ! $host ]]; then continue; fi
 
   while read -r ip host mac opts; do
     if [[ $ip == *#*  || ! $host ]]; then continue; fi
-    if [[ $opts == vpn ]]; then
+
+    # opt parsing
+    vpn=false
+    root=false
+    for opt in $opts; do
+      case $opt in
+        user=root)
+          root=true
+          ;;
+        vpn)
+          vpn=true
+          ;;
+      esac
+    done
+
+    all_ips[$host]=$ip
+    if $vpn; then
       vpn_ips[$host]=$ip
     else
       nonvpn_ips[$host]=$ip
     fi
       vpn_ips[$host]=$ip
     else
       nonvpn_ips[$host]=$ip
     fi
-
-
-    if [[ $opts == user=root ]]; then
-      # note: the b8.nz suffix is for the User part, the IdentityFile
-      # part is redundant to *.b8.nz.
-      root_hosts+=($host i$host $host.b8.nz i$host.b8.nz)
+    if $root; then
+      # note: the reason we have b8.nz suffix here but not for non_root
+      # hosts is that it is for the User part, the IdentityFile part is
+      # redundant to *.b8.nz. Also note ${host}i, we only setup those for vpn hosts, but there is no harm in overspecifying here.
+      root_hosts+=($host ${host}i $host.b8.nz ${host}i.b8.nz)
     else
     else
-      nonroot_hosts+=($host i$host)
+      nonroot_hosts+=($host ${host}i)
     fi
 
     host_ips[$host]=$ip
     host_macs[$host]=$mac
   done </p/c/host-info
 
     fi
 
     host_ips[$host]=$ip
     host_macs[$host]=$mac
   done </p/c/host-info
 
-  cedit /p/c/subdir_files/.ssh/config <<EOF || [[ $? == 1 ]]
+  {
+    cat <<EOF
 Host ${nonroot_hosts[@]}
 User iank
 IdentityFile ~/.ssh/home
 
 Host ${root_hosts[@]}
 IdentityFile ~/.ssh/home
 Host ${nonroot_hosts[@]}
 User iank
 IdentityFile ~/.ssh/home
 
 Host ${root_hosts[@]}
 IdentityFile ~/.ssh/home
+
 EOF
 EOF
+    for host in ${!vpn_ips[@]}; do
+      ipsuf=${vpn_ips[$host]}
+      cat <<EOF
+Host ${host}i
+Hostname b8.nz
+Port $((2200 + ipsuf))
+
+EOF
+    done
+
+    # convenience of one auth key entry
+    for host in ${!all_ips[@]}; do
+      cat <<EOF
+Host $host ${host}i $host.b8.nz ${host}i.b8.nz
+HostKeyAlias $host.b8.nz
+EOF
+    done
+  } | cedit /p/c/subdir_files/.ssh/config || [[ $? == 1 ]]
+
+  {
+    echo "cat <<EOF"
+    for host in ${!vpn_ips[@]}; do
+      ipsuf=${vpn_ips[$host]}
+      i_port=$(( 2200 + ipsuf ))
+      cat <<EOF
+config redirect
+ option name ssh$host
+ option src              wan
+ option src_dport        $i_port
+ option dest_port        22
+ option dest_ip          \$l.$ipsuf
+ option dest             lan
+config rule
+ option src              wan
+ option target           ACCEPT
+ option dest_port        $i_port
+EOF
+    done
+    echo "EOF"
+  } >/p/c/cmc-firewall-data
 
 
   local host ipsuf f files
 
 
 
   local host ipsuf f files
 
+  # shellcheck disable=SC2016 # shellcheck doesnt know this is sed
   sedi '/edits below here are made automatically/,$d' /p/c/machine_specific/li/filesystem/etc/wireguard/wgmail.conf
   for host in ${!vpn_ips[@]}; do
     ipsuf=${vpn_ips[$host]}
   sedi '/edits below here are made automatically/,$d' /p/c/machine_specific/li/filesystem/etc/wireguard/wgmail.conf
   for host in ${!vpn_ips[@]}; do
     ipsuf=${vpn_ips[$host]}
@@ -2735,6 +2796,7 @@ EOF
     echo "cat <<EOF"
     for host in ${!host_ips[@]}; do
       ipsuf=${host_ips[$host]}
     echo "cat <<EOF"
     for host in ${!host_ips[@]}; do
       ipsuf=${host_ips[$host]}
+      # shellcheck disable=SC2016 # intentional
       echo 'local-data-ptr: "$l.'$ipsuf $host.b8.nz'"'
     done
     echo "EOF"
       echo 'local-data-ptr: "$l.'$ipsuf $host.b8.nz'"'
     done
     echo "EOF"
index ea01214b794f878981459b45af86f70b5d41714f..d7fa65831328beb8567ffdaa65a57e54afba90d6 100755 (executable)
@@ -198,7 +198,7 @@ EOF
       # as I know.
       f=debian-archive-keyring_2023.3+deb12u1_all.deb
       wget http://ftp.debian.org/debian/pool/main/d/debian-archive-keyring/$f
       # as I know.
       f=debian-archive-keyring_2023.3+deb12u1_all.deb
       wget http://ftp.debian.org/debian/pool/main/d/debian-archive-keyring/$f
-      dpkg -i $f
+      sudo dpkg -i $f
       p update
       cd -
       rm -rf $tmpdir
       p update
       cd -
       rm -rf $tmpdir
index ebeaae110806afc489a6eebbd600ac0561186376..1d4608195c6bfc8f147d778433882f20b09eb413 100755 (executable)
@@ -93,6 +93,24 @@ m a2dismod php$phpver ||:
 m a2enmod proxy_fcgi
 
 
 m a2enmod proxy_fcgi
 
 
+cedit /etc/php/$phpver/fpm/php.ini <<'EOF'
+
+# fixes warning on /settings/admin/overview about 8 being too small.
+opcache.interned_strings_buffer=64
+
+# while I was googling for what to set the above to, I found a
+#recommendation to increase this from 128 to 512, and we set 512 somewhere
+# else in the  config.
+opcache.memory_consumption=512
+EOF
+
+# https://docs.nextcloud.com/server/29/admin_manual/installation/source_installation.html
+sed -ri 's/;env\[(HOSTNAME|PATH|TMP|TMPDIR|TEMP)\]/env[\1]/' /etc/php/8.1/fpm/pool.d/www.conf
+
+# yes, it is a bit stupid to uncomment then change it
+sed -ri 's,^env\[PATH\] =.*,env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,' /etc/php/8.1/fpm/pool.d/www.conf
+
+/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 
 m web-conf - apache2 $domain <<EOF
 ### begin nextcloud settings
 
 m web-conf - apache2 $domain <<EOF
 ### begin nextcloud settings
@@ -149,7 +167,7 @@ EOF
 
 
 
 
 
 
-nextcloud_admin_pass=casHiosidZyFraycs
+nextcloud_admin_pass=$(tail -n1 /p/c/nextcloud-admin-pass)
 
 m cd /var/www
 if [[ ! -e $ncdir/index.php ]]; then
 
 m cd /var/www
 if [[ ! -e $ncdir/index.php ]]; then