diff --git a/README.md b/README.md index f4a5bcd..400b5fd 100644 --- a/README.md +++ b/README.md @@ -122,9 +122,14 @@ The installation script will: 1. Edit environment variables: ```bash -sudo nano /opt/kspguti-schedule/.env.production +sudo nano /opt/kspguti-schedule/.env ``` +The installation script will: +- Copy `.env` file from source directory if it exists +- Preserve existing `.env` in installation directory if it already exists +- Create `.env` from `.env.production.example` if no `.env` file is found + 2. Update systemd service if needed: ```bash sudo nano /etc/systemd/system/kspguti-schedule.service @@ -178,7 +183,7 @@ sudo journalctl -u kspguti-schedule -f **Environment variables:** -See `.env.production.example` for available options: +See `.env.production.example` or `.example.env` for available options. The application uses `.env` file in production: - `PROXY_URL` - URL for schedule parsing (optional) - `PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_BOTAPI_TOKEN` - Telegram bot token (optional) - `PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_CHAT_ID` - Telegram chat ID (optional) diff --git a/scripts/install.sh b/scripts/install.sh index a0948a0..14dee4b 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -133,16 +133,25 @@ rsync -av --exclude='node_modules' \ --exclude='.next' \ --exclude='.git' \ --exclude='*.log' \ - --exclude='.env*' \ + --exclude='.env.local' \ + --exclude='.env.development' \ + --exclude='.env.development.local' \ + --exclude='.env.test' \ + --exclude='.env.test.local' \ --exclude='*.md' \ "$PROJECT_DIR/" "$INSTALL_DIR/" -# Create .env.production if it doesn't exist -if [ ! -f "$INSTALL_DIR/.env.production" ]; then - echo -e "${YELLOW}Creating .env.production from example...${NC}" +# Handle .env file +if [ -f "$PROJECT_DIR/.env" ] && [ ! -f "$INSTALL_DIR/.env" ]; then + echo -e "${YELLOW}Copying .env file...${NC}" + cp "$PROJECT_DIR/.env" "$INSTALL_DIR/.env" +elif [ -f "$INSTALL_DIR/.env" ]; then + echo -e "${GREEN}Using existing .env file in installation directory${NC}" +else + echo -e "${YELLOW}No .env file found. Creating from example...${NC}" if [ -f "$INSTALL_DIR/.env.production.example" ]; then - cp "$INSTALL_DIR/.env.production.example" "$INSTALL_DIR/.env.production" - echo -e "${YELLOW}Please edit $INSTALL_DIR/.env.production with your configuration${NC}" + cp "$INSTALL_DIR/.env.production.example" "$INSTALL_DIR/.env" + echo -e "${YELLOW}Please edit $INSTALL_DIR/.env with your configuration${NC}" fi fi @@ -191,7 +200,7 @@ systemctl enable "$SERVICE_NAME.service" echo -e "\n${GREEN}=== Installation completed successfully! ===${NC}\n" echo -e "${YELLOW}Next steps:${NC}" -echo -e "1. Edit environment variables: ${GREEN}$INSTALL_DIR/.env.production${NC}" +echo -e "1. Edit environment variables: ${GREEN}$INSTALL_DIR/.env${NC}" echo -e "2. Update systemd service if needed: ${GREEN}/etc/systemd/system/$SERVICE_NAME.service${NC}" echo -e "3. Start the service: ${GREEN}systemctl start $SERVICE_NAME${NC}" echo -e "4. Check status: ${GREEN}systemctl status $SERVICE_NAME${NC}" diff --git a/systemd/kspguti-schedule.service b/systemd/kspguti-schedule.service index 2868f79..eb7c79b 100644 --- a/systemd/kspguti-schedule.service +++ b/systemd/kspguti-schedule.service @@ -17,7 +17,7 @@ Environment=HOSTNAME=0.0.0.0 # Environment=PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_CHAT_ID=your_chat_id_here # Load environment variables from file (optional) -# EnvironmentFile=/opt/kspguti-schedule/.env.production +# EnvironmentFile=/opt/kspguti-schedule/.env # Use standalone server from Next.js build ExecStart=/usr/bin/node /opt/kspguti-schedule/.next/standalone/server.js