# AutoMate Project ## Overview AutoMate is a one-person IT automation project designed to streamline and automate administrative tasks. This project aims to minimize manual work for tasks such as document processing, task management, billing, and reporting through open-source, on-premise tools. ## Project Structure - **docs/**: Documentation for setup, usage, and maintenance. - **src/**: Main codebase, including Docker configuration and automation scripts. - **configs/**: Configuration files for different services. - **configs/nginx**: Configuration files for the NGINX reverse proxy. - **docker/**: Docker Compose configuration files. - **scripts/**: Custom scripts (e.g., for installation, SSL certificate generation). - **data/**: Persistent data storage (e.g., databases). - **logs/**: Application logs. ## Environment Variables Create a `.env` file in the project root with the following placeholders (to be replaced with actual values): ```bash # Paperless-ngx Configuration PAPERLESS_DB_USER=myuser PAPERLESS_DB_PASSWORD=randomGeneratedPassword PAPERLESS_SECRET_KEY=randomGeneratedSecret # Nextcloud Configuration NEXTCLOUD_ADMIN_USER=admin NEXTCLOUD_ADMIN_PASSWORD=randomGeneratedPassword # Database Configuration for Nextcloud MYSQL_ROOT_PASSWORD=randomGeneratedPassword MYSQL_DATABASE=nextcloud MYSQL_USER=nextcloud MYSQL_PASSWORD=randomGeneratedPassword # Kimai Database Configuration KIMAI_DB_DATABASE=kimai KIMAI_DB_USER=kimai_user KIMAI_DB_PASSWORD=randomGeneratedPassword KIMAI_DB_ROOT_PASSWORD=randomGeneratedPassword # Kimai Admin User Configuration KIMAI_ADMIN_USER=kiami_admin_user KIMAI_ADMIN_PASSWORD=randomGeneratedPassword KIMAI_ADMIN_EMAIL=kiami@admin.email # Keycloak Configuration KEYCLOAK_ADMIN_USER=admin KEYCLOAK_ADMIN_PASSWORD=randomGeneratedPassword KEYCLOAK_DB=keycloak KEYCLOAK_DB_USERNAME=keycloak_user KEYCLOAK_DB_PASSWORD=randomGeneratedPassword # N8N Configuration N8N_USER=n8n_user N8N_PASSWORD=randomGeneratedPassword ``` ## Installation ### Start Docker Script To start all Docker services after a reset, you can use the `start_docker.sh` script located in the `src/scripts` directory. Use the following command to run the script: ```bash cd ~/AutoMate/src/scripts ./start_docker.sh ``` This script will ensure that all necessary data directories are created before starting Docker Compose. ### Docker Reset Script To reset all Docker data, including containers, images, volumes, and networks, you can use the `reset_docker.sh` script located in the `src/scripts` directory. Use the following command to run the script: ```bash cd ~/AutoMate/src/scripts ./reset_docker.sh [-d] ``` - Use the `-d` option to also delete persistent data directories. To reset all Docker data, including containers, images, volumes, and networks, you can use the `reset_docker.sh` script located in the `src/scripts` directory. Use the following command to run the script: ```bash cd ~/AutoMate/src/scripts ./reset_docker.sh [-d] ``` **Note**: This will delete all Docker data and return Docker to a clean state. Use with caution. - Use the `-d` option to also delete persistent data directories. ### Step 1: Install Docker To install Docker on a new system, you can use the provided installation script. Run the following commands in the `src/scripts` directory: ```bash cd ~/AutoMate/src/scripts ./install_docker.sh ``` This script will install Docker and add the current user to the Docker group. **Note:** You will need to log out and log back in for the group permissions to take effect. ### Step 2: Docker Compose Setup 1. **Navigate to the Docker Config Directory**: ```bash cd ~/AutoMate/src/docker ``` 2. **Create Necessary Data Directories**: Before starting Docker Compose, ensure the data directories exist. You can create them using the following commands: ```bash mkdir -p ~/AutoMate/data/keycloak mkdir -p ~/AutoMate/data/keycloak_db ``` 3. **Start Docker Compose**: Use Docker Compose to start all configured services. ```bash docker-compose up -d ``` 4. **Check Status**: To confirm that all services are running, use: ```bash docker-compose ps ``` ## SSL Certificate Setup The project includes a script to generate self-signed SSL certificates for local development. 1. **Run the SSL Generation Script**: ```bash cd ~/AutoMate/src/scripts ./generate_ssl_certificate.sh -d "mrx8086.com" -o "../configs/certs" -t 365 -p "yourPfxPassword" ``` 2. **Generated Files**: - `.crt` and `.key` files for NGINX in `configs/certs`. - `.pfx` file for importing into Windows to prevent SSL errors. ## NGINX Reverse Proxy NGINX is used as a reverse proxy to route traffic to different services via subdomains (e.g., `auth.mrx8086.com` for Keycloak). ### Configuration The NGINX configuration is stored in `src/configs/nginx/nginx.conf`. It is set up to handle: - **Keycloak** at `auth.mrx8086.com` - **Nextcloud** at `cloud.mrx8086.com` - **Paperless** at `docs.mrx8086.com` - **Kimai** at `time.mrx8086.com` - **n8n** at `automate.mrx8086.com` Make sure to add these subdomains to your hosts file for local testing. ## Creating an Admin User for Paperless-ngx After starting the Paperless-ngx service for the first time, you need to create a superuser (admin) account to access the interface. Follow these steps: 1. **Run the following command in your project directory to enter the Paperless-ngx container**: ```bash docker-compose exec paperless python3 manage.py createsuperuser ``` 2. **Provide the Required Information**: - Enter a **username** for the admin account. - Provide an **email address**. - Set a **password**. 3. **Log In to Paperless-ngx**: - Open your web browser and go to `http://docs.mrx8086.com`. - Use the username and password you just created to log in as the admin. ## Setting Up Kimai (Time Tracking) 1. **Access Kimai**: - Open your web browser and go to `http://time.mrx8086.com`. - Log in with the `KIMAI_ADMIN_USER` and `KIMAI_ADMIN_PASSWORD` values you set in `.env`. ## Keycloak Setup 1. **Run Keycloak**: - Start Keycloak by running `docker-compose up -d keycloak`. - Access the Keycloak admin console at [http://auth.mrx8086.com](http://auth.mrx8086.com) with the credentials set in `.env`. 2. **Create a Realm and Clients**: - Create a new realm for centralized user management. - Set up clients for Nextcloud, Kimai, and Paperless if they support it. 3. **Connecting Applications**: - Configure Nextcloud, Kimai, and other tools to authenticate via Keycloak by setting them as clients in Keycloak. - Follow Keycloak documentation for setting up clients with OpenID Connect. ## Accessing Services Each service can be accessed using the following URLs: - **Paperless-ngx**: [http://docs.mrx8086.com](http://docs.mrx8086.com) - **Nextcloud**: [http://cloud.mrx8086.com](http://cloud.mrx8086.com) - **Kimai**: [http://time.mrx8086.com](http://time.mrx8086.com) - **n8n**: [http://automate.mrx8086.com](http://automate.mrx8086.com) - **Keycloak**: [http://auth.mrx8086.com](http://auth.mrx8086.com) ## Contributing Please ensure any modifications are tested locally before pushing changes to the repository. All environment variables should be stored in `.env` and sensitive information should not be committed to the repository.