Browse Source

Shell script style pass

master
Causal Agent 1 month ago
parent
commit
76c6a9b42a
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
7 changed files with 62 additions and 61 deletions
  1. 3
    3
      bin/html.sh
  2. 3
    3
      etc/tf/link.sh
  3. 13
    13
      install.sh
  4. 12
    12
      link.sh
  5. 4
    4
      prune.sh
  6. 7
    7
      www/text.causal.agency/Makefile
  7. 20
    19
      www/text.causal.agency/feed.sh

+ 3
- 3
bin/html.sh View File

@@ -6,9 +6,9 @@ readonly GiteaURL='https://code.causal.agency/june/src/src/branch/master/bin'
src=$1
man=${2:-}

./hi -f html -o document,tab=4 -n "${src}" /dev/null | sed '/<pre/d'
./hi -f html -o document,tab=4 -n "$src" /dev/null | sed '/<pre/d'
cat <<- EOF
<code><a href="${GiteaURL}/${src}">${src} in git</a></code>
EOF
[ -f "${man}" ] && man -P cat "${PWD}/${man}" | ./ttpre
./hi -f html -o anchor "${src}"
[ -f "$man" ] && man -P cat "${PWD}/${man}" | ./ttpre
./hi -f html -o anchor "$src"

+ 3
- 3
etc/tf/link.sh View File

@@ -1,7 +1,7 @@
#!/bin/sh
set -e -u
set -eu

tf="$HOME/Library/Application Support/Steam/steamapps/common/Team Fortress 2/tf"
tf="${HOME}/Library/Application Support/Steam/steamapps/common/Team Fortress 2/tf"
for cfg in cfg/*.cfg; do
ln -s -f "$PWD/$cfg" "$tf/$cfg"
ln -fs "${PWD}/${cfg}" "${tf}/${cfg}"
done

+ 13
- 13
install.sh View File

@@ -15,25 +15,25 @@ Darwin() {
if [ ! -d /opt/pkg ]; then
tar="bootstrap-trunk-x86_64-${pkgsrcTag}.tar.gz"
url="https://pkgsrc.joyent.com/packages/Darwin/bootstrap/${tar}"
curl -O "${url}"
sudo tar -pxz -f "${tar}" -C /
rm "${tar}"
curl -O "$url"
sudo tar -pxz -f "$tar" -C /
rm "$tar"
fi
sudo pkgin update
sudo pkgin install ${pkgDarwin}
sudo pkgin install $pkgDarwin
sudo ln -fs /opt/pkg/bin/gpg2 /usr/local/bin/gpg
if [ ! -f /usr/local/bin/nvim ]; then
tar="nvim-macos.tar.gz"
base="https://github.com/neovim/neovim/releases/download"
tar='nvim-macos.tar.gz'
base='https://github.com/neovim/neovim/releases/download'
url="${base}/${neovimTag}/${tar}"
curl -L -O "${url}"
sudo tar -x -f "${tar}" -C /usr/local --strip-components 1
rm "${tar}"
curl -L -O "$url"
sudo tar -x -f "$tar" -C /usr/local --strip-components 1
rm "$tar"
fi
}

FreeBSD() {
pkg install ${pkgFreeBSD}
pkg install $pkgFreeBSD
}

NetBSD() {
@@ -41,15 +41,15 @@ NetBSD() {
base="ftp://ftp.NetBSD.org/pub/pkgsrc/packages"
export PKG_PATH="${base}/$(uname -s)/$(uname -p)/$(uname -r)/All"
pkg_add pkgin
echo "${PKG_PATH}" > /usr/pkg/etc/pkgin/repositories.conf
echo "$PKG_PATH" > /usr/pkg/etc/pkgin/repositories.conf
fi
pkgin update
pkgin install ${pkgNetBSD}
pkgin install $pkgNetBSD
ln -fs /usr/pkg/bin/gpg2 /usr/local/bin/gpg
}

Linux() {
pacman -Sy --needed ${pkgLinux}
pacman -Sy --needed $pkgLinux
}

$(uname)

+ 12
- 12
link.sh View File

@@ -1,18 +1,18 @@
#!/bin/sh
set -e -u
set -eu

if [ $# -eq 1 ]; then
linkPath=$1
filePath="$PWD/home/${linkPath#$HOME/}"
[ ! -f "$filePath" ]
mkdir -p "$(dirname "$filePath")"
mv "$linkPath" "$filePath"
link=$1
file="${PWD}/home/${link#${HOME}/}"
[ ! -f "$file" ]
mkdir -p "${file%/*}"
mv "$link" "$file"
fi

find home -type f | while read -r findPath; do
filePath="$PWD/$findPath"
linkPath="$HOME/${findPath#home/}"
mkdir -p "$(dirname "$linkPath")"
[ \( -f "$linkPath" -a -L "$linkPath" \) -o ! -f "$linkPath" ]
ln -s -f "$filePath" "$linkPath"
find home -type f | while read -r find; do
file="${PWD}/${find}"
link="${HOME}/${find#home/}"
mkdir -p "${link%/*}"
[ \( -f "$link" -a -L "$link" \) -o ! -f "$link" ]
ln -fs "$file" "$link"
done

+ 4
- 4
prune.sh View File

@@ -1,7 +1,7 @@
#!/bin/sh
set -e -u
set -eu

find -L ~ -type l -lname "$PWD/*" | while read -r linkPath; do
rm "$linkPath"
echo "$linkPath"
find -L ~ -type l -lname "${PWD}/*" | while read -r link; do
echo "$link"
rm "$link"
done

+ 7
- 7
www/text.causal.agency/Makefile View File

@@ -6,18 +6,18 @@ TXTS += 003-pleasant-c.txt
TXTS += 004-uloc.txt
TXTS += 005-testing-c.txt

all: $(TXTS)
all: ${TXTS}

.SUFFIXES: .7 .txt

.7.txt:
mandoc $< | col -b -x > $@
mandoc $< | col -bx > $@

feed.atom: $(TXTS)
./feed.sh > feed.atom
feed.atom: feed.sh ${TXTS}
sh feed.sh > feed.atom

clean:
rm -f $(TXTS) feed.atom
rm -f ${TXTS} feed.atom

install: $(TXTS) feed.atom
install -p -m 644 $(TXTS) feed.atom $(WEBROOT)
install: ${TXTS} feed.atom
install -p -m 644 ${TXTS} feed.atom ${WEBROOT}

+ 20
- 19
www/text.causal.agency/feed.sh View File

@@ -1,29 +1,30 @@
#!/bin/sh
set -e -u
set -eu

updated=$(date -u '+%FT%TZ')
cat <<EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Causal Agency</title>
<author><name>June</name><email>june@causal.agency</email></author>
<link href="https://text.causal.agency"/>
<id>https://text.causal.agency/</id>
<updated>${updated}</updated>
cat <<- EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Causal Agency</title>
<author><name>June</name><email>june@causal.agency</email></author>
<link href="https://text.causal.agency"/>
<id>https://text.causal.agency/</id>
<updated>${updated}</updated>
EOF
for entry in *.7; do
url="https://text.causal.agency/${entry%.7}.txt"
title=$(grep '^\.Nm' "$entry" | cut -c 5-)
summary=$(grep '^\.Nd' "$entry" | cut -c 5-)
updated=$(date -j -u -f '%s' "$(stat -f '%m' "$entry")" '+%FT%TZ')
cat <<EOF
<entry>
<title>${title}</title>
<summary>${summary}</summary>
<link href="${url}"/>
<id>${url}</id>
<updated>${updated}</updated>
</entry>
EOF
mtime=$(stat -f '%m' "$entry")
updated=$(date -ju -f '%s' "$mtime" '+%FT%TZ')
cat <<- EOF
<entry>
<title>${title}</title>
<summary>${summary}</summary>
<link href="${url}"/>
<id>${url}</id>
<updated>${updated}</updated>
</entry>
EOF
done
echo '</feed>'

Loading…
Cancel
Save