Add Notesnook-install.sh

bash -c "$(curl -fsSL http://192.168.1.43:3000/maq/helper-scripts/raw/branch/main/Notesnook-install.sh)"
This commit is contained in:
maq
2025-08-23 07:12:29 -07:00
parent 56fff5b852
commit e690d1e784

129
Notesnook-install.sh Normal file
View File

@@ -0,0 +1,129 @@
#!/bin/bash
# Notesnook Sync Server Installation Script for Proxmox LXC (Debian)
# Run this script inside your LXC container after creation
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}Starting Notesnook Sync Server installation...${NC}"
# Update system and install prerequisites
echo -e "${YELLOW}Updating system and installing prerequisites...${NC}"
apt-get update
apt-get install -y curl gnupg apt-transport-https ca-certificates software-properties-common
# Install Docker
echo -e "${YELLOW}Installing Docker...${NC}"
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
# Enable and start Docker
systemctl enable docker
systemctl start docker
# Install Docker Compose
echo -e "${YELLOW}Installing Docker Compose...${NC}"
DOCKER_COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# Verify installations
echo -e "${YELLOW}Verifying installations...${NC}"
docker --version
docker-compose --version
# Create directory for Notesnook
echo -e "${YELLOW}Creating Notesnook directory...${NC}"
mkdir -p /opt/notesnook
cd /opt/notesnook
# Create docker-compose.yml file
echo -e "${YELLOW}Creating docker-compose.yml...${NC}"
cat > docker-compose.yml << 'EOF'
version: '3.8'
services:
notesnook:
image: streetwriters/notesnook-sync-server:latest
container_name: notesnook-sync-server
restart: unless-stopped
ports:
- "5262:5262"
environment:
- NODE_ENV=production
- DATABASE_URL=sqlite3:///data/db.sqlite3
- REDIS_URL=redis://redis:6379
- STORAGE_DIR=/data/storage
- JWT_SECRET=change_this_to_a_secure_random_string
- ENCRYPTION_KEY=change_this_to_another_secure_random_string
volumes:
- ./data:/data
depends_on:
- redis
networks:
- notesnook-network
redis:
image: redis:7-alpine
container_name: notesnook-redis
restart: unless-stopped
command: redis-server --appendonly yes
volumes:
- ./redis-data:/data
networks:
- notesnook-network
networks:
notesnook-network:
driver: bridge
EOF
# Create data directory
mkdir -p data redis-data
# Generate secure secrets
echo -e "${YELLOW}Generating secure secrets...${NC}"
JWT_SECRET=$(openssl rand -base64 32)
ENCRYPTION_KEY=$(openssl rand -base64 32)
# Update docker-compose.yml with generated secrets
sed -i "s|JWT_SECRET=change_this_to_a_secure_random_string|JWT_SECRET=${JWT_SECRET}|g" docker-compose.yml
sed -i "s|ENCRYPTION_KEY=change_this_to_another_secure_random_string|ENCRYPTION_KEY=${ENCRYPTION_KEY}|g" docker-compose.yml
# Start Notesnook Sync Server
echo -e "${YELLOW}Starting Notesnook Sync Server...${NC}"
docker-compose up -d
# Wait for services to start
echo -e "${YELLOW}Waiting for services to start...${NC}"
sleep 10
# Check if services are running
echo -e "${YELLOW}Checking service status...${NC}"
docker-compose ps
# Display installation summary
echo -e "${GREEN}===================================================${NC}"
echo -e "${GREEN}Notesnook Sync Server Installation Complete!${NC}"
echo -e "${GREEN}===================================================${NC}"
echo -e "${YELLOW}Server URL:${NC} http://$(hostname -I | awk '{print $1}'):5262"
echo -e "${YELLOW}Data directory:${NC} /opt/notesnook/data"
echo -e "${YELLOW}Redis data:${NC} /opt/notesnook/redis-data"
echo -e "${YELLOW}To view logs:${NC} cd /opt/notesnook && docker-compose logs -f"
echo -e "${YELLOW}To stop:${NC} cd /opt/notesnook && docker-compose stop"
echo -e "${YELLOW}To start:${NC} cd /opt/notesnook && docker-compose start"
echo -e "${YELLOW}To restart:${NC} cd /opt/notesnook && docker-compose restart"
echo -e "${GREEN}===================================================${NC}"
echo -e "${YELLOW}Next steps:${NC}"
echo -e "1. Configure your Notesnook client to use your server URL"
echo -e "2. In Notesnook app settings, set sync server to: http://YOUR_SERVER_IP:5262"
echo -e "${GREEN}===================================================${NC}"