Brennan's Gemini Blog

Home
About
Guide
smol.pub

Making a Guestbook (and log) for the Tildeverse

This guide shows how to set up a shared guestbook on a tildeverse server, with logging to track who added entries and when.

Overview

This setup creates:

• A guestbook.txt file for public entries (read-only, script-accessible only)

• A guestbook.log file to track changes (writable)

• A script that adds entries with timestamps and user attribution

• Secure permissions that prevent direct file editing while allowing script access

Setup Instructions

1. Create the Guestbook File

micro ~/guestbook.txt

Then, add a header like this:

# Guestbook
============

2. Create the Log File

micro ~/guestbook.log

Add this content to the file:

# Guestbook Change Log
# Format: [timestamp] username: action

3. Create the Add Entry Script

Create a script called ~/guestbook-add.sh:

micro ~/guestbook-add.sh

Add this content to the script:

#!/bin/sh
# Guestbook entry script with logging
# Usage: ./guestbook-add.sh

GUESTBOOK="$HOME/guestbook.txt"
LOGFILE="$HOME/guestbook.log"
DATE=$(date '+%Y-%m-%d %H:%M:%S')
USERNAME=$(whoami)

# Check if guestbook exists
if [ ! -f "$GUESTBOOK" ]; then
    echo "Error: Guestbook file not found at $GUESTBOOK"
    exit 1
fi

# Log the action
echo "[$DATE] $USERNAME: Added entry" >> "$LOGFILE"

# Create temp file for content validation
TEMPFILE=$(mktemp)

# Prompt for entry (if interactive) or read from stdin
if [ -t 0 ]; then
    echo "Enter your guestbook entry (press Ctrl+D when done):"
    cat > "$TEMPFILE"
else
    cat > "$TEMPFILE"
fi

# Add separator and entry
echo "" >> "$GUESTBOOK"
echo "---" >> "$GUESTBOOK"
echo "Added by $USERNAME on $DATE:" >> "$GUESTBOOK"
echo "" >> "$GUESTBOOK"

# Add the content
cat "$TEMPFILE" >> "$GUESTBOOK"
echo "" >> "$GUESTBOOK"

# Clean up
rm "$TEMPFILE"

echo "Entry added to guestbook!"

4. Make the Script Executable

chmod +x ~/guestbook-add.sh

5. Set Permissions

Make the guestbook file read-only (only accessible via script), but keep the log writable:

chmod 644 ~/guestbook.txt
chmod 666 ~/guestbook.log
chmod 755 ~/guestbook-add.sh

This setup ensures:

• Users can only add entries via the script

• Direct editing of guestbook.txt is prevented

• The log file remains writable for tracking changes

Usage

Adding an Entry

Interactive mode:

~/guestbook-add.sh

Then type your entry and press Ctrl+D when done.

Piping Content

You can also pipe content to the script:

echo "Hello from the tildeverse!" | ~/guestbook-add.sh

Or from a file:

cat my-entry.txt | ~/guestbook-add.sh

Viewing the Guestbook

cat ~/guestbook.txt
less ~/guestbook.txt

Viewing the Log

cat ~/guestbook.log
tail ~/guestbook.log          # Show recent entries

Advanced Features

Create a View Script

Create ~/guestbook-view.sh:

micro ~/guestbook-view.sh

Add this content:

#!/bin/sh
# View guestbook with recent changes

echo "=== GUESTBOOK ==="
cat ~/guestbook.txt
echo ""
echo "=== RECENT CHANGES ==="
tail -10 ~/guestbook.log

Make it executable:

chmod +x ~/guestbook-view.sh

Create a Clear Script

Create ~/guestbook-clear.sh (use with caution!):

micro ~/guestbook-clear.sh

Add this content:

#!/bin/sh
# Clear guestbook (requires confirmation)

echo "This will clear the guestbook. Are you sure? (yes/no)"
read answer
if [ "$answer" = "yes" ]; then
    DATE=$(date '+%Y-%m-%d %H:%M:%S')
    USERNAME=$(whoami)
    echo "[$DATE] $USERNAME: Cleared guestbook" >> ~/guestbook.log
    echo "# Guestbook" > ~/guestbook.txt
    echo "============" >> ~/guestbook.txt
    echo "" >> ~/guestbook.txt
    echo "Guestbook cleared."
else
    echo "Operation cancelled."
fi

Make it executable:

chmod +x ~/guestbook-clear.sh

Security Considerations

Current Setup

• Users can only add entries via the script

• Direct editing of guestbook.txt is prevented (644 permissions)

• Changes are logged with username and timestamp

• Script provides controlled access with attribution

• Log file remains writable for tracking

Why This Approach?

• Prevents accidental deletion or corruption

• Ensures all entries are logged and attributed

• Maintains consistent formatting

• Allows for future content filtering in the script

• Reduces risk of malicious content injection

Additional Security Options

1. Group-based Access

If your tilde server supports groups:

# Create a group (requires admin access)
# Add trusted users to the group
chgrp guestbook-users ~/guestbook.txt
chmod 664 ~/guestbook.txt

2. Content Filtering

Add basic content filtering to the script:

# Add to guestbook-add.sh after the cat command
# Filter out common spam patterns
TEMPFILE=$(mktemp)
cat > "$TEMPFILE"

if grep -qi "viagra\|casino\|lottery\|porn" "$TEMPFILE"; then
    echo "Entry rejected: inappropriate content detected"
    rm "$TEMPFILE"
    exit 1
fi

cat "$TEMPFILE" >> "$GUESTBOOK"
rm "$TEMPFILE"

Maintenance

Regular Cleanup

Archive old entries periodically:

# Create archive
cp ~/guestbook.txt ~/guestbook-$(date +%Y%m).txt
# Clear current file
~/guestbook-clear.sh

Log Rotation

Prevent log files from growing too large:

# Archive old logs
mv ~/guestbook.log ~/guestbook-$(date +%Y%m).log
touch ~/guestbook.log
echo "# Guestbook Change Log" > ~/guestbook.log

Check File Sizes

ls -lh ~/guestbook*

Integration with Other Services

Email Notifications

Add email notification to the script:

# Add to guestbook-add.sh
echo "New guestbook entry from $USERNAME" | mail -s "Guestbook Update" your-email@tilde.pink

Gemini Display

Create a gemini version of your guestbook:

mkdir -p ~/public_gemini
ln -s ~/guestbook.txt ~/public_gemini/guestbook.gmi

Your guestbook will be available at:

gemini://tilde.pink/~username/guestbook.gmi

Troubleshooting

Permission Denied on Script

chmod +x ~/guestbook-add.sh
chmod +x ~/guestbook-view.sh
chmod +x ~/guestbook-clear.sh

Log File Permission Issues

chmod 666 ~/guestbook.log

Guestbook File Permission Issues

The guestbook should be read-only (644) - users access it via the script:

chmod 644 ~/guestbook.txt

Entries Not Appearing

Check file permissions and ownership:

ls -l ~/guestbook*

Script Won't Run

Ensure the script is executable and you have proper permissions:

ls -l ~/guestbook-add.sh

Log File Growing Too Large

Implement log rotation (see Maintenance section)

Alternative Approaches

1. Web-based Guestbook

If your tilde server supports web hosting, consider using a proper guestbook application.

2. Email-based System

Have users email entries to you, then add them manually.

3. Git-based Version Control

Use git to track changes:

cd ~
git init
git add guestbook.txt guestbook.log
git commit -m "Initial guestbook setup"

Community Guidelines

Consider adding a header to your guestbook:

# Guestbook Guidelines
# • Be respectful and kind
# • No spam or self-promotion
# • Keep entries relatively short
# • This is a public space, be mindful of what you share

Main Site
Gemini capsule
Contact

© 2026 Brennan Kenneth Brown. Content available under CC BY-SA