Skip to content

Commit 449c6f5

Browse files
feat: read from file
1 parent b17eeca commit 449c6f5

2 files changed

Lines changed: 69 additions & 60 deletions

File tree

README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,34 @@ This webhook provider allows Kubernetes external-dns to automatically create, up
3838

3939
### One-Line Installation
4040

41-
SSH into your Firewalla as the `pi` user and run:
41+
SSH into your Firewalla as the `pi` user and run these two commands:
4242

4343
```bash
44-
curl -fsSL https://raw.githubusercontent.com/TheOutdoorProgrammer/external-dns-firewalla-webhook/main/scripts/install.sh | bash -s -- "home.local,*.home.local"
44+
# Step 1: Create config file with your domain filter
45+
echo "home.local,*.home.local" > /tmp/external-dns-domain-filter
46+
47+
# Step 2: Run the installer
48+
curl -fsSL https://raw.githubusercontent.com/TheOutdoorProgrammer/external-dns-firewalla-webhook/main/scripts/install.sh | bash
4549
```
4650

47-
**Important**: Replace `home.local,*.home.local` with your actual domain filter.
51+
**Important**: Replace `home.local,*.home.local` with your actual domain filter in step 1.
4852

4953
**Note**: The script will prompt for your sudo password when needed for system configuration.
5054

5155
This will:
56+
- Verify your domain filter configuration
5257
- Clone the repository (with bundled dependencies)
5358
- Verify dependencies
5459
- Configure the service (with sudo)
5560
- Set up your domain filter
5661
- Start the webhook provider
62+
- Clean up the temporary config file
5763

5864
**Note**: Dependencies (Express.js) are bundled in the repository since npm is not available on Firewalla.
5965

60-
### Interactive Installation
66+
### Manual Installation
6167

62-
If you prefer an interactive installation that prompts for configuration:
68+
If you prefer to review the installation script first:
6369

6470
1. SSH into your Firewalla device as the `pi` user:
6571
```bash
@@ -77,28 +83,25 @@ If you prefer an interactive installation that prompts for configuration:
7783
cat scripts/install.sh
7884
```
7985

80-
4. Run the installation script (as pi user, not root):
86+
4. Create the domain filter config file:
8187
```bash
82-
./scripts/install.sh
88+
echo "home.local,*.home.local" > /tmp/external-dns-domain-filter
8389
```
8490

85-
The script will ask for your sudo password and domain filter when needed.
91+
Replace `home.local,*.home.local` with your actual domains.
8692

87-
5. Enter your domain filter when prompted (e.g., `home.local,*.home.local`)
93+
5. Run the installation script (as pi user, not root):
94+
```bash
95+
./scripts/install.sh
96+
```
97+
98+
The script will ask for your sudo password when needed.
8899

89100
6. Verify the service is running:
90101
```bash
91102
sudo systemctl status external-dns-firewalla-webhook
92103
```
93104

94-
### Alternative: Pass Domain Filter as Argument
95-
96-
You can also provide the domain filter directly:
97-
98-
```bash
99-
./scripts/install.sh "home.local,*.home.local"
100-
```
101-
102105
### Configuration in Kubernetes
103106

104107
#### Using Helm Chart (Recommended)

scripts/install.sh

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
# This script installs and configures the webhook provider on Firewalla
55
#
66
# Usage:
7-
# ./scripts/install.sh [domain-filter]
8-
# curl -fsSL https://raw.githubusercontent.com/.../install.sh | bash -s -- "example.com,*.example.com"
7+
# 1. Create config file with your domain filter:
8+
# echo "home.local,*.home.local" > /tmp/external-dns-domain-filter
9+
# 2. Run the installation:
10+
# curl -fsSL https://raw.githubusercontent.com/.../install.sh | bash
911
#
1012
set -e
1113

@@ -15,22 +17,57 @@ GREEN='\033[0;32m'
1517
YELLOW='\033[1;33m'
1618
NC='\033[0m' # No Color
1719

18-
# Get domain filter from first argument if provided
19-
DOMAIN_FILTER="${1:-}"
20-
2120
# Configuration
2221
INSTALL_DIR="/opt/external-dns-firewalla-webhook"
2322
SERVICE_NAME="external-dns-firewalla-webhook"
2423
SERVICE_FILE="external-dns-firewalla-webhook.service"
2524
DNSMASQ_DIR="/home/pi/.firewalla/config/dnsmasq_local"
2625
SUDOERS_FILE="/etc/sudoers.d/external-dns-webhook"
2726
GITHUB_REPO="https://github.com/TheOutdoorProgrammer/external-dns-firewalla-webhook.git"
27+
CONFIG_FILE="/tmp/external-dns-domain-filter"
2828

2929
echo "========================================="
3030
echo "External-DNS Firewalla Webhook Installer"
3131
echo "========================================="
3232
echo ""
3333

34+
# Check for config file first
35+
if [ ! -f "$CONFIG_FILE" ]; then
36+
echo -e "${RED}ERROR: Configuration file not found${NC}"
37+
echo ""
38+
echo "Before running this installer, you must create a config file with your domain filter."
39+
echo ""
40+
echo "Step 1: Create the config file with your domain(s):"
41+
echo " echo \"home.local,*.home.local\" > $CONFIG_FILE"
42+
echo ""
43+
echo "Step 2: Run the installer:"
44+
echo " curl -fsSL https://raw.githubusercontent.com/TheOutdoorProgrammer/external-dns-firewalla-webhook/main/scripts/install.sh | bash"
45+
echo ""
46+
echo "For interactive installation:"
47+
echo " git clone $GITHUB_REPO"
48+
echo " cd external-dns-firewalla-webhook"
49+
echo " echo \"home.local,*.home.local\" > $CONFIG_FILE"
50+
echo " ./scripts/install.sh"
51+
echo ""
52+
exit 1
53+
fi
54+
55+
# Read domain filter from config file
56+
DOMAIN_FILTER=$(cat "$CONFIG_FILE" | tr -d '\n\r' | xargs)
57+
58+
if [ -z "$DOMAIN_FILTER" ]; then
59+
echo -e "${RED}ERROR: Config file is empty${NC}"
60+
echo ""
61+
echo "The file $CONFIG_FILE exists but contains no domain filter."
62+
echo "Please add your domain filter to the file:"
63+
echo " echo \"home.local,*.home.local\" > $CONFIG_FILE"
64+
echo ""
65+
exit 1
66+
fi
67+
68+
echo -e "${GREEN}Found domain filter:${NC} $DOMAIN_FILTER"
69+
echo ""
70+
3471
# Check if running as pi user
3572
if [ "$(whoami)" != "pi" ]; then
3673
echo -e "${RED}ERROR: Please run as pi user (not root)${NC}"
@@ -123,44 +160,13 @@ echo "Dependencies verified (bundled in repository)"
123160

124161
# Configure environment
125162
echo -e "${GREEN}[6/9]${NC} Configuring environment..."
126-
if [ ! -s "$INSTALL_DIR/.env" ] || ! grep -q "DOMAIN_FILTER=" "$INSTALL_DIR/.env" || grep -q "DOMAIN_FILTER=example.com" "$INSTALL_DIR/.env"; then
127-
# If domain filter not provided as argument, try to read from stdin
128-
if [ -z "$DOMAIN_FILTER" ]; then
129-
# Check if stdin is a terminal (interactive)
130-
if [ -t 0 ]; then
131-
echo ""
132-
echo -e "${YELLOW}Please enter your domain filter (comma-separated, e.g., example.com,*.example.com):${NC}"
133-
read -p "Domain filter: " DOMAIN_FILTER
134-
else
135-
# Not interactive (piped from curl)
136-
echo ""
137-
echo -e "${RED}ERROR: Domain filter is required but not provided${NC}"
138-
echo ""
139-
echo "When using the one-line install, provide your domain filter as an argument:"
140-
echo ""
141-
echo " curl -fsSL https://raw.githubusercontent.com/.../install.sh | bash -s -- \"example.com,*.example.com\""
142-
echo ""
143-
echo "Alternatively, run the installation interactively:"
144-
echo ""
145-
echo " git clone $GITHUB_REPO"
146-
echo " cd external-dns-firewalla-webhook"
147-
echo " ./scripts/install.sh"
148-
echo ""
149-
exit 1
150-
fi
151-
fi
152-
153-
if [ -z "$DOMAIN_FILTER" ]; then
154-
echo -e "${RED}ERROR: Domain filter cannot be empty${NC}"
155-
exit 1
156-
fi
157-
158-
# Update .env file
159-
sed -i "s/DOMAIN_FILTER=.*/DOMAIN_FILTER=$DOMAIN_FILTER/" "$INSTALL_DIR/.env"
160-
echo "Domain filter configured: $DOMAIN_FILTER"
161-
else
162-
echo "Using existing .env configuration"
163-
fi
163+
# Update .env file with domain filter from config file
164+
sed -i "s/DOMAIN_FILTER=.*/DOMAIN_FILTER=$DOMAIN_FILTER/" "$INSTALL_DIR/.env"
165+
echo "Domain filter configured: $DOMAIN_FILTER"
166+
167+
# Clean up config file after successful configuration
168+
rm -f "$CONFIG_FILE"
169+
echo "Removed temporary config file"
164170

165171
# Create dnsmasq directory
166172
echo -e "${GREEN}[7/9]${NC} Creating dnsmasq directory..."

0 commit comments

Comments
 (0)