Skip to content

Instantly share code, notes, and snippets.

@thibaultmol
Created March 15, 2023 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thibaultmol/379490007fe571eeee660b689d099589 to your computer and use it in GitHub Desktop.
Save thibaultmol/379490007fe571eeee660b689d099589 to your computer and use it in GitHub Desktop.
reply to Reddit user rergarding obsidian remote
#!/bin/bash -x
# This is a reply to https://www.reddit.com/r/ObsidianMD/comments/11rw50n/comment/jcagzq4/?utm_source=reddit&utm_medium=web2x&context=3
echo "Updating the package list and installing Docker..."
sudo apt-get update
sudo apt-get install -y docker.io
echo "Installing Nginx Proxy Manager (NPM) in a Docker container..."
sudo docker run -d --name npm -p 81:81 -p 443:443 -v npmdata:/data --restart always jlesage/nginx-proxy-manager
echo "Waiting for NPM to start up before proceeding..."
until sudo docker exec npm /bin/bash -c "curl -s http://localhost:81 > /dev/null"; do sleep 5 done
echo "Testing if NPM is running..."
if sudo docker logs npm | grep -q "Error"; then
echo "NPM failed to start up. Check the Docker logs for more information."
exit 1
else
echo "NPM is running."
fi
echo "Getting the ID of the NPM network for later use..."
NETWORK_ID=$(sudo docker network ls --filter name=npm_app_net -q)
echo "Installing Obsidian-Remote in a Docker container..."
sudo docker run -d --name obsidian-remote -p 127.0.0.1:8080:8080 -v /home/obsidian/vaults:/vaults -v /home/obsidian/config:/config -e PUID=1000 -e PGID=1000 -e TZ=America/Los_Angeles -e DOCKER_MODS=linuxserver/mods:universal-git --network $NETWORK_ID ghcr.io/sytone/obsidian-remote:latest
echo "Getting the IP address of the instance..."
SERVER_IP=$(curl -s http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip -H "Metadata-Flavor: Google")
echo "Configuring Nginx Proxy Manager..."
sudo docker exec npm npm-config set server.api_url http://localhost:81/api/
sudo docker exec npm npm-config set server.websocket_url ws://localhost:81/
sudo docker exec npm npm-config set server.bind_address 0.0.0.0
sudo docker exec npm npm-config set server.http_port 81
sudo docker exec npm npm-config set server.https_port 443
echo "Asking the user to enter their email address..."
read -p "Enter your email address for Nginx Proxy Manager: " email_address
sudo docker exec npm npm-config set server.lets_encrypt.email $email_address
echo "Asking the user to enter their desired NPM admin password..."
read -p "Enter your desired Nginx Proxy Manager admin password: " npm_password
sudo docker exec npm npm-config set server.default_password $npm_password
echo "Creating a new Nginx Proxy Manager host..."
sudo docker exec npm npm-cli add \ --name "Obsidian-Remote" \ --domain "" \ --ip-addresses "$SERVER_IP" \ --target "http://obsidian-remote:8080"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment