From: Ian Kelling Date: Thu, 28 Apr 2022 03:19:36 +0000 (-0400) Subject: tons of updates, should have checked in sooner X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=6d5364acaf732814110b7ab98ef1d266276f64ee;p=buildscripts tons of updates, should have checked in sooner --- diff --git a/alacritty b/alacritty new file mode 100755 index 0000000..dcf68f6 --- /dev/null +++ b/alacritty @@ -0,0 +1,14 @@ +#!/bin/bash +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: GPL-3.0-or-later + +source /a/bin/errhandle/err +source /a/bin/distro-functions/src/package-manager-abstractions + + +pi cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3 +cd /a/opt/alacritty +cargo build --release +sudo mkdir -p /usr/local/share/man/man1 +gzip -c extra/alacritty.man | sudo tee /usr/local/share/man/man1/alacritty.1.gz > /dev/null +sudo rsync -at /a/opt/alacritty/target/release/alacritty /usr/local/bin diff --git a/emacs b/emacs index d6fd0c0..b9cc53b 100755 --- a/emacs +++ b/emacs @@ -22,10 +22,12 @@ update=false bootstrap=false recompile=false show_pkgs=false +dryrun=false while [[ $1 == -* ]]; do case $1 in -b) bootstrap=true; recompile=true ;; + -n) dryrun=true ;; -r) recompile=true ;; --no-r) recompile=false ;; -u) update=true ;; @@ -58,7 +60,8 @@ for x in {35..25} ""; do fi done -pkgs=(gawk attr autoconf-archive git install-info) +# ccache is a missing build dep for mu +pkgs=(gawk attr autoconf-archive git install-info ccache) ##### warning, apt-rdepends seems to look at the newest version of the package, ##### not the one that build-dep would install. if $show_pkgs; then @@ -89,8 +92,11 @@ last_build=$dir/iank-emacs-build # e/e because autofs failing to mount will make it so # you cant ls whatever directory it is in, so we -# need an extra directory -dirs=($dir $dir-nox/.iank/e/e) +# need an extra directory. i dunno why this was like this instead of just $dir-nox. +#dirs=($dir $dir-nox/.iank/e/e) + +dirs=($dir $dir-nox) + if [[ -e $dir ]]; then m cd $dir @@ -108,6 +114,11 @@ else bootstrap=true fi +if $dryrun; then + echo recompile=$recompile bootstrap=$bootstrap update=$update + exit 0 +fi + if $bootstrap; then m rsync --delete -ra /a/opt/emacs/ $dir recompile=true @@ -120,7 +131,7 @@ case $(distro-name) in ;;& debian|ubuntu|trisquel) # todo: unknown for other distros, this will fail - logq p -y build-dep maildir-utils/$(debian-codename) + logq p -y build-dep maildir-utils # oddly, on ubuntu 14.04 this installs postfix, but I dun care # ubuntu 14.04 gave this error message # Unable to satisfy the build-depends: Build-Depends: libpng-dev @@ -138,17 +149,22 @@ if $recompile; then nox=false for d in ${dirs[@]}; do if $nox; then - # todo: this doesnt account for - m mkdir -p ${d%/*} + # Commented stuff in this block had something to do with ssh / autofs, im not really using nox right now, + # so unless I figure out why it was this way, ignore this. + # m mkdir -p ${d%/*} m rsync --delete -ra $dir/ $d - mp=$HOME/.iank/e/e - if mountpoint $mp &>/dev/null; then - m sudo umount $mp - fi - m mkdir -p $mp - m sudo mount -o bind $d $mp - m sudo chown $USER:$USER $mp - m cd $mp + # + # mp=$HOME/.iank/e/e + # if mountpoint $mp &>/dev/null; then + # m sudo umount $mp + # fi + # m mkdir -p $mp + # m sudo mount -o bind $d $mp + # m sudo chown $USER:$USER $mp + # m cd $mp + + # instead of $mp above + m cd $d else m cd $d fi diff --git a/kitty b/kitty new file mode 100755 index 0000000..ab611e6 --- /dev/null +++ b/kitty @@ -0,0 +1,64 @@ +#!/bin/bash + +source /a/bin/errhandle/err + +if [[ -s ~/.bashrc ]]; then . ~/.bashrc; fi + +rebuild=false +case $1 in + -r) rebuild=true ;; +esac + +# https://sw.kovidgoyal.net/kitty/build/ +deps=( + libdbus-1-dev + libxcursor-dev + libxrandr-dev + libxi-dev + libxinerama-dev + libgl1-mesa-dev + libxkbcommon-x11-dev + libfontconfig-dev + libx11-xcb-dev + liblcms2-dev + libpython3-dev + librsync-dev +) + +pi ${deps[@]} + +cd /a/opt/kitty +rev=$(cat $last_build 2>/dev/null) ||: +head=$(git rev-parse HEAD) +if ! $recompile && ! $bootstrap && [[ $rev == "$head" ]]; then + : +fi + + +# built it on one machine, the others it dies with the error illegal +# instruction. building is pretty quick, so just detect if our version +# works, and if not, rebuild and install. +# I had an idea to test the failure like so: +# timeout 5 kitty /bin/true, but that doesn't work over ssh +if ! $rebuild && ! /bin/true; then + rebuild=true +fi + +if $rebuild; then + s mkdir -p /usr/local/src/kitty + s mount -o bind /a/opt/kitty /usr/local/src/kitty + + s install -o zu -g zu -d /usr/local/src/kitty + s chown -hR zu.zu /usr/local/src/kitty + cd /usr/local/src/kitty + m sudo -u zu firejail --read-write=/usr/local/src/kitty --profile=makekitty make clean + m sudo -u zu firejail --read-write=/usr/local/src/kitty --profile=makekitty make + cd / + s umount /usr/local/src/kitty + s chown -hR iank.iank /a/opt/kitty +fi + +cd /a/opt/kitty +s rsync -ar --chown root:root --delete __main__.py kitty logo kittens /usr/local/src/kitty +s rsync -ar --chown root:root ./terminfo/x/xterm-kitty /usr/share/terminfo/x/xterm-kitty +s ln -sf -T /usr/local/src/kitty/kitty/launcher/kitty /usr/local/bin/kitty diff --git a/mumble b/mumble new file mode 100755 index 0000000..b118cac --- /dev/null +++ b/mumble @@ -0,0 +1,43 @@ +#!/bin/bash +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: AGPL-3.0-or-later + +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR + +if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi + +deps=( + build-essential + cmake + pkg-config + qt5-default + qttools5-dev + qttools5-dev-tools + libqt5svg5-dev + libboost-dev + libssl-dev + libprotobuf-dev + protobuf-compiler + libprotoc-dev + libcap-dev + libxi-dev + libasound2-dev + libogg-dev + libsndfile1-dev + libspeechd-dev + libavahi-compat-libdnssd-dev + libxcb-xinerama0 + libzeroc-ice-dev + libpoco-dev +) +pi ${deps[@]} + +mkc /a/opt/mumble/build + +# just looked through cmake_options.md and picked things that looked good. oss, alsa, portaudio, pipewire are off just to avoid superflous options we dont use. +cmake -Dcoreaudio=OFF -Dzeroconf=OFF -Doss=OFF -Dportaudio=OFF -Dalsa=OFF -Dpipewire=OFF -Dserver=OFF -Doverlay-xcompile=OFF -Doverlay=OFF -Dupdate=OFF -Dwasapi=OFF -Dxboxinput=OFF -Dlto=ON -Doptimize=ON .. + +make -j $(nproc) diff --git a/nodejs b/nodejs new file mode 100755 index 0000000..ed8f199 --- /dev/null +++ b/nodejs @@ -0,0 +1,18 @@ +#!/bin/bash + +#https://github.com/nodesource/distributions/blob/master/README.md +KEYRING=/usr/share/keyrings/nodesource.gpg +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo dd of=$KEYRING 2>/dev/null + + +# Replace with the branch of Node.js or io.js you want to install: node_6.x, node_8.x, etc... +VERSION=node_16.x +# Replace with the keyring above, if different +KEYRING=/usr/share/keyrings/nodesource.gpg +# The below command will set this correctly, but if lsb_release isn't available, you can set it manually: +# - For Debian distributions: jessie, sid, etc... +# - For Ubuntu distributions: xenial, bionic, etc... +# - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README. +DISTRO=focal +echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list +echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list diff --git a/prom-node-exporter b/prom-node-exporter new file mode 100755 index 0000000..4263b3e --- /dev/null +++ b/prom-node-exporter @@ -0,0 +1,263 @@ +#!/bin/bash + +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR + +[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + + +usage() { + cat </dev/null; then + apt-get -y install $p + fi + done +fi +if $do_setup && ! type -t rsync &>/dev/null; then + # note: we could use diff or cmp instead. + apt-get -y install rsync +fi + +sysd_reload=false +installed_file=false + +i() { # install file + local tmp tmpdir dest="$1" + local base="${dest##*/}" + local dir="${dest%/*}" + if [[ $dir != "$base" ]]; then + # dest has a directory component + mkdir -p "$dir" + fi + tmpdir=$(mktemp -d) + cat >$tmpdir/"$base" + tmp=$(rsync -ic $tmpdir/"$base" "$dest") + if [[ $tmp ]]; then + printf "%s\n" "$tmp" + installed_file=true + if [[ $dest == /etc/systemd/system/* ]]; then + sysd_reload=true + fi + fi + rm -rf $tmpdir +} + + +if $dl_bin; then + if [[ -s /usr/local/src/node-exporter-url ]]; then + installed_url=$(cat /usr/local/src/node-exporter-url) + fi + url=$(curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest | jq -r '.assets[].browser_download_url | match(".*linux-amd64.tar.gz$").string') + if [[ ! $url ]]; then + echo $0: error failed to get url + exit 1 + fi + if [[ $url != "$installed_url" ]]; then + tmpdir=$(mktemp -d) + cd $tmpdir + f=${url##*/} + wget -nv $url + tar -xf $f + dir=${f%.tar.gz} + install $dir/node_exporter /usr/local/bin/prometheus-node-exporter + printf "%s\n" "$url" >/usr/local/src/node-exporter-url + cd + rm -rf $tmpdir + fi +fi + +if ! $do_setup; then + exit 0 +fi + +# taken from postinstall script +if ! getent passwd prometheus &>/dev/null; then + adduser --quiet --system --home /var/lib/prometheus --no-create-home \ + --group --gecos "Prometheus daemon" prometheus +fi + + +# textfile collector dir +mkdir -p /var/lib/prometheus/node-exporter + +chown prometheus:prometheus /var/lib/prometheus + + +i /etc/default/prometheus-node-exporter < +# Author: Guillem Jover + +DESC="Prometheus exporter for machine metrics" +NAME=prometheus-node-exporter +USER=prometheus +GROUP=$USER +DAEMON=/usr/bin/$NAME +PIDFILE=/run/prometheus/$NAME.pid +LOGFILE=/var/log/prometheus/$NAME.log + +START_ARGS="--no-close --background --make-pidfile" +STOP_ARGS="--remove-pidfile" + +do_start_prepare() +{ + mkdir -p $(dirname $PIDFILE) +} + +do_start_cmd_override() +{ + start-stop-daemon --start --quiet --oknodo \ + --exec $DAEMON --pidfile $PIDFILE --user $USER --group $GROUP \ + --chuid $USER:$GROUP $START_ARGS -- $ARGS >>$LOGFILE 2>&1 +} + +do_stop_cmd_override() +{ + start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 \ + --exec $DAEMON --pidfile $PIDFILE --user $USER $STOP_ARGS +} + +alias do_reload=do_reload_sigusr1 +EOF + chmod +x /etc/init.d/prometheus-node-exporter + + mkdir -p /var/log/prometheus + chown prometheus:prometheus /var/log/prometheus + update-rc.d prometheus-node-exporter defaults + + running=false + if type -t pgrep &>/dev/null && pgrep -f prometheus-node-exporter &>/dev/null; then + running=true + fi + if $installed_file || ! $running; then + /etc/init.d/prometheus-node-exporter restart + fi + + i /etc/logrotate.d/prometheus-node-exporter <<'EOF' +/var/log/prometheus/prometheus-node-exporter.log { + weekly + rotate 10 + copytruncate + compress + delaycompress + notifempty + missingok +} +EOF + +fi diff --git a/prometheus b/prometheus new file mode 100755 index 0000000..e7e3233 --- /dev/null +++ b/prometheus @@ -0,0 +1,45 @@ +#!/bin/bash + +# I initially was using these +# https://github.com/cloudalchemy/ansible-prometheus +# https://github.com/cloudalchemy/ansible-alertmanager +# https://github.com/cloudalchemy/ansible-node-exporter +# https://github.com/cloudalchemy/ansible-grafana + +# As of trisquel 11, get upstream prom because it has the react ui, +# which has localtime, and general better usability. alertmanager, +# changelog seems to show good changes and surely things will just work +# better with a matching prometheus. + +if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi + +#rsync --delete consoles console_libraries /etc/prometheus + + +while read -r prog tool; do + cd /a/opt/${prog}dl + url=$(curl -s https://api.github.com/repos/prometheus/$prog/releases/latest | jq -r '.assets[].browser_download_url | match(".*linux-amd64.tar.gz$").string') + f=${url##*/} + if [[ -e $f ]]; then + timestamp=$(stat -c %Y $f) + else + timestamp=0 + fi + m wget -nv -N $url + new_timestamp=$(stat -c %Y $f) + if [[ $timestamp != $new_timestamp || ! -e /usr/local/bin/$prog ]]; then + ngset + to_rm=( !($f) ) + ngreset + if (( ${#to_rm[@]} )); then + rm -rf ${to_rm[@]} + fi + m ex $f + dir=${f%.tar.gz} + m sudo install $dir/$prog $dir/$tool /usr/local/bin + m sudo systemctl restart $prog + fi +done <<'EOF' +prometheus promtool +alertmanager amtool +EOF diff --git a/tor-browser b/tor-browser index df4dd8c..9b3212c 100755 --- a/tor-browser +++ b/tor-browser @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi +if [[ -s ~/.bashrc ]]; then . ~/.bashrc; fi # stable version is shown on: @@ -24,11 +24,16 @@ if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi # we exclude verions with letters, as that seems to # be a relatively reliable indication of alpha/beta releases. -vers=($(curl -s https://dist.torproject.org/torbrowser/ \ - | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p' \ - | sort -Vr)) - - +# Their server has failed a few times on me, so do some retrying. +for (( i=0; i <= 6 ; i++ )); do + c=$(curl -s https://dist.torproject.org/torbrowser/) && break + sleep 15 +done +if [[ ! $c ]]; then + echo "$0: error: failed to curl tor directory listing" >&2 + exit 1 +fi +vers=($(printf "%s\n" "$c" | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p' | sort -Vr)) # by default it has perms for just 1 non-root user, which is ok for now.