Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add separate install/build.sh files (#374)
Leendert de Borst6b8f0d6cdf64
diff --git a/README.md b/README.mdindex 3f5e90303..ad79d539b 100644--- a/README.md+++ b/README.md@@ -35,6 +35,11 @@ A live demo of the app is available at the official website at [app.aliasvault.n<img width="700" alt="Screenshot of AliasVault" src="docs/img/screenshot.png">## Installation++Choose one of the following installation methods:++### Option 1: Quick Install (using pre-built images)+To install AliasVault on your local machine, follow the steps below. Note: the install process is tested on MacOS and Linux. It should work on Windows too, but you might need to adjust some commands.### Requirements:@@ -42,18 +47,27 @@ To install AliasVault on your local machine, follow the steps below. Note: the i- Docker- Git-### 1. Clone and run install script+### 1. Quick Install (using pre-built images)AliasVault comes with a install script that prepares the .env file, builds the Docker image, and starts the AliasVault containers.```bash-# Clone this Git repository to "AliasVault" directory-$ git clone https://github.com/lanedirt/AliasVault.git+# Download install script+curl -o install.sh https://raw.githubusercontent.com/lanedirt/AliasVault/main/install.sh-# Go to the project directory-$ cd AliasVault+# Make install script executable and run it+chmod +x install.sh+./install.sh+```++### 2. Build from Source+```bash+# Clone the repository+git clone https://github.com/lanedirt/AliasVault.git+cd AliasVault-# Make install script executable and run it.-$ chmod +x install.sh && ./install.sh+# Make build script executable and run it+chmod +x build.sh+./build.sh```Note: if you do not wish to run the script, you can set up the environment variables and build the Docker image and containers manually instead. See the [manual setup instructions](docs/install/1-manually-setup-docker.md) for more information.diff --git a/build.sh b/build.shnew file mode 100755index 000000000..cc188084a--- /dev/null+++ b/build.sh@@ -0,0 +1,76 @@+#!/bin/bash++# Import common functions+source common.sh++# Function to build and run Docker Compose+build_and_run_docker_compose() {+ printf "${CYAN}> Building Docker Compose stack...${NC}"+ if [ "$VERBOSE" = true ]; then+ docker compose -f docker-compose.yml -f docker-compose.build.yml build+ else+ (+ docker compose -f docker-compose.yml -f docker-compose.build.yml build > install_compose_build_output.log 2>&1 &+ BUILD_PID=$!+ while kill -0 $BUILD_PID 2>/dev/null; do+ printf "."+ sleep 1+ done+ wait $BUILD_PID+ BUILD_EXIT_CODE=$?+ if [ $BUILD_EXIT_CODE -ne 0 ]; then+ printf "\n${RED}> An error occurred while building the Docker Compose stack. Check install_compose_build_output.log for details.${NC}\n"+ exit $BUILD_EXIT_CODE+ fi+ )+ fi+ printf "\n${GREEN}> Docker Compose stack built successfully.${NC}\n"++ printf "${CYAN}> Starting Docker Compose stack...${NC}\n"+ if [ "$VERBOSE" = true ]; then+ docker compose -f docker-compose.yml -f docker-compose.build.yml up -d+ else+ docker compose -f docker-compose.yml -f docker-compose.build.yml up -d > /dev/null 2>&1+ fi+ printf "${GREEN}> Docker Compose stack started successfully.${NC}\n"+}++# Main function+main() {+ parse_args "$@"+ print_logo++ if [ "$RESET_PASSWORD" = true ]; then+ generate_admin_password+ if [ $? -eq 0 ]; then+ restart_docker_containers+ print_password_reset_message+ fi+ else+ printf "${YELLOW}+++ Building AliasVault from source +++${NC}\n"+ printf "\n"++ # Initialize environment+ create_env_file || exit $?+ populate_hostname || exit $?+ populate_jwt_key || exit $?+ populate_data_protection_cert_pass || exit $?+ set_private_email_domains || exit $?+ set_smtp_tls_enabled || exit $?+ set_support_email || exit $?++ # Only generate admin password if not already set+ if ! grep -q "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" || [ -z "$(grep "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" | cut -d '=' -f2)" ]; then+ generate_admin_password || exit $?+ fi++ printf "\n${YELLOW}+++ Building and starting services +++${NC}\n"+ printf "\n"+ build_and_run_docker_compose || exit $?++ print_success_message+ fi+}++# Run the main function+main "$@"diff --git a/common.sh b/common.shnew file mode 100644index 000000000..303ef5aa0--- /dev/null+++ b/common.sh@@ -0,0 +1,220 @@+#!/bin/bash++# Color codes for output+RED='\033[0;31m'+GREEN='\033[0;32m'+YELLOW='\033[1;33m'+BLUE='\033[0;34m'+MAGENTA='\033[0;35m'+CYAN='\033[0;36m'+NC='\033[0m'++# File paths+ENV_FILE=".env"+ENV_EXAMPLE_FILE=".env.example"++# Function to parse command line arguments+parse_args() {+ RESET_PASSWORD=false+ VERBOSE=false++ while [[ $# -gt 0 ]]; do+ case $1 in+ --reset-admin-password|--reset-password)+ RESET_PASSWORD=true+ shift+ ;;+ --verbose)+ VERBOSE=true+ shift+ ;;+ *)+ echo "Unknown option: $1"+ exit 1+ ;;+ esac+ done+}++# Function to print the logo+print_logo() {+ printf "${BLUE}"+ printf " _ _ _ __ __ _ _ \n"+ printf " / \ | (_) __ _ ___ \ \ / /_ _ _ _| | |_\n"+ printf " / _ \ | | |/ _\` / __| \ \/\/ / _\` | | | | | __|\n"+ printf " / ___ \| | | (_| \__ \ \ / (_| | |_| | | |_ \n"+ printf "/_/ \_\_|_|\__,_|___/ \/ \__,_|\__,_|_|\__|\n"+ printf "${NC}\n"+}++# Function to create .env file+create_env_file() {+ printf "${CYAN}> Creating .env file...${NC}\n"+ if [ ! -f "$ENV_FILE" ]; then+ if [ -f "$ENV_EXAMPLE_FILE" ]; then+ cp "$ENV_EXAMPLE_FILE" "$ENV_FILE"+ printf "${GREEN}> .env file created from .env.example.${NC}\n"+ else+ touch "$ENV_FILE"+ printf "${YELLOW}> .env file created as empty because .env.example was not found.${NC}\n"+ fi+ else+ printf "${GREEN}> .env file already exists.${NC}\n"+ fi+}++# Environment setup functions+populate_hostname() {+ printf "${CYAN}> Checking HOSTNAME...${NC}\n"+ if ! grep -q "^HOSTNAME=" "$ENV_FILE" || [ -z "$(grep "^HOSTNAME=" "$ENV_FILE" | cut -d '=' -f2)" ]; then+ DEFAULT_HOSTNAME="localhost"+ read -p "Enter the hostname where AliasVault will be hosted (press Enter for default: $DEFAULT_HOSTNAME): " USER_HOSTNAME+ HOSTNAME=${USER_HOSTNAME:-$DEFAULT_HOSTNAME}+ update_env_var "HOSTNAME" "$HOSTNAME"+ else+ HOSTNAME=$(grep "^HOSTNAME=" "$ENV_FILE" | cut -d '=' -f2)+ fi+}++populate_jwt_key() {+ printf "${CYAN}> Checking JWT_KEY...${NC}\n"+ if ! grep -q "^JWT_KEY=" "$ENV_FILE" || [ -z "$(grep "^JWT_KEY=" "$ENV_FILE" | cut -d '=' -f2)" ]; then+ JWT_KEY=$(openssl rand -base64 32)+ update_env_var "JWT_KEY" "$JWT_KEY"+ fi+}++populate_data_protection_cert_pass() {+ printf "${CYAN}> Checking DATA_PROTECTION_CERT_PASS...${NC}\n"+ if ! grep -q "^DATA_PROTECTION_CERT_PASS=" "$ENV_FILE" || [ -z "$(grep "^DATA_PROTECTION_CERT_PASS=" "$ENV_FILE" | cut -d '=' -f2)" ]; then+ CERT_PASS=$(openssl rand -base64 32)+ update_env_var "DATA_PROTECTION_CERT_PASS" "$CERT_PASS"+ fi+}++set_private_email_domains() {+ printf "${CYAN}> Checking PRIVATE_EMAIL_DOMAINS...${NC}\n"+ if ! grep -q "^PRIVATE_EMAIL_DOMAINS=" "$ENV_FILE" || [ -z "$(grep "^PRIVATE_EMAIL_DOMAINS=" "$ENV_FILE" | cut -d '=' -f2)" ]; then+ DEFAULT_DOMAINS="localmail.tld"+ read -p "Enter comma-separated list of private email domains (press Enter for default: $DEFAULT_DOMAINS): " USER_DOMAINS+ DOMAINS=${USER_DOMAINS:-$DEFAULT_DOMAINS}+ update_env_var "PRIVATE_EMAIL_DOMAINS" "$DOMAINS"+ fi+}++set_smtp_tls_enabled() {+ printf "${CYAN}> Checking SMTP_TLS_ENABLED...${NC}\n"+ if ! grep -q "^SMTP_TLS_ENABLED=" "$ENV_FILE"; then+ update_env_var "SMTP_TLS_ENABLED" "false"+ fi+}++set_support_email() {+ printf "${CYAN}> Checking SUPPORT_EMAIL...${NC}\n"+ if ! grep -q "^SUPPORT_EMAIL=" "$ENV_FILE"; then+ read -p "Enter support email address (optional, press Enter to skip): " SUPPORT_EMAIL+ update_env_var "SUPPORT_EMAIL" "$SUPPORT_EMAIL"+ fi+}++generate_admin_password() {+ printf "${CYAN}> Generating admin password...${NC}\n"+ PASSWORD=$(openssl rand -base64 12)++ # Use pre-built image from GitHub Container Registry+ if ! docker pull ghcr.io/lanedirt/aliasvault-initcli:latest > /dev/null 2>&1; then+ printf "${YELLOW}> Pre-built image not found, building locally...${NC}"+ if [ "$VERBOSE" = true ]; then+ docker build -t initcli -f src/Utilities/AliasVault.InstallCli/Dockerfile .+ else+ (+ docker build -t initcli -f src/Utilities/AliasVault.InstallCli/Dockerfile . > install_build_output.log 2>&1 &+ BUILD_PID=$!+ while kill -0 $BUILD_PID 2>/dev/null; do+ printf "."+ sleep 1+ done+ printf "\n"+ wait $BUILD_PID+ BUILD_EXIT_CODE=$?+ if [ $BUILD_EXIT_CODE -ne 0 ]; then+ printf "\n${RED}> Error building Docker image. Check install_build_output.log for details.${NC}\n"+ exit $BUILD_EXIT_CODE+ fi+ )+ fi+ HASH=$(docker run --rm initcli "$PASSWORD")+ else+ HASH=$(docker run --rm ghcr.io/lanedirt/aliasvault-initcli:latest "$PASSWORD")+ fi++ # Update env vars+ update_env_var "ADMIN_PASSWORD_HASH" "$HASH"+ update_env_var "ADMIN_PASSWORD_GENERATED" "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"++ printf " ==> New admin password: $PASSWORD\n"+}++# Helper function to update environment variables+update_env_var() {+ local key=$1+ local value=$2+ if grep -q "^$key=" "$ENV_FILE"; then+ sed -i.bak "s|^$key=.*|$key=$value|" "$ENV_FILE" && rm "$ENV_FILE.bak"+ else+ echo "$key=$value" >> "$ENV_FILE"+ fi+ printf "${GREEN}> $key has been set in $ENV_FILE.${NC}\n"+}++# Function to print success message+print_success_message() {+ printf "\n"+ printf "${MAGENTA}=========================================================${NC}\n"+ printf "\n"+ printf "${GREEN}AliasVault is successfully installed!${NC}\n"+ printf "\n"+ printf "${CYAN}To configure the server, login to the admin panel:${NC}\n"+ printf "\n"+ if [ -n "$PASSWORD" ]; then+ printf "Admin Panel: https://${HOSTNAME}/admin\n"+ printf "Username: admin\n"+ printf "Password: $PASSWORD\n"+ printf "\n"+ printf "${YELLOW}(!) Caution: Make sure to backup the above credentials in a safe place, they won't be shown again!${NC}\n"+ else+ printf "Admin Panel: https://${HOSTNAME}/admin\n"+ printf "Username: admin\n"+ printf "Password: (Previously set. Use --reset-password to generate new one.)\n"+ fi+ printf "\n"+ printf "${CYAN}===========================${NC}\n"+ printf "\n"+ printf "${CYAN}In order to start using AliasVault, log into the client website:${NC}\n"+ printf "\n"+ printf "Client Website: https://${HOSTNAME}/\n"+ printf "\n"+ printf "${MAGENTA}=========================================================${NC}\n"+}++# Function to restart Docker containers+restart_docker_containers() {+ printf "${CYAN}> Restarting Docker containers...${NC}\n"+ if [ "$VERBOSE" = true ]; then+ docker compose restart+ else+ docker compose restart > /dev/null 2>&1+ fi+ printf "${GREEN}> Docker containers restarted.${NC}\n"+}++# Function to print password reset success message+print_password_reset_message() {+ printf "\n"+ printf "${MAGENTA}=========================================================${NC}\n"+ printf "\n"+ printf "${GREEN}The admin password is successfully reset, see the output above. You can now login to the admin panel using this new password.${NC}\n"+ printf "\n"+ printf "${MAGENTA}=========================================================${NC}\n"+ printf "\n"+}\ No newline at end of filediff --git a/docker-compose.build.yml b/docker-compose.build.ymlnew file mode 100644index 000000000..7bf51b094--- /dev/null+++ b/docker-compose.build.yml@@ -0,0 +1,30 @@+services:+ reverse-proxy:+ image: aliasvault-reverse-proxy+ build:+ context: .+ dockerfile: Dockerfile++ client:+ image: aliasvault-client+ build:+ context: .+ dockerfile: src/AliasVault.Client/Dockerfile++ api:+ image: aliasvault-api+ build:+ context: .+ dockerfile: src/AliasVault.Api/Dockerfile++ admin:+ image: aliasvault-admin+ build:+ context: .+ dockerfile: src/AliasVault.Admin/Dockerfile++ smtp:+ image: aliasvault-smtp+ build:+ context: .+ dockerfile: src/Services/AliasVault.SmtpService/Dockerfile\ No newline at end of filediff --git a/docker-compose.yml b/docker-compose.ymlindex 7ecb7b7b5..267320bed 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -1,9 +1,6 @@services:reverse-proxy:- image: aliasvault-reverse-proxy- build:- context: .- dockerfile: Dockerfile+ image: ghcr.io/lanedirt/aliasvault-reverse-proxy:latestports:- "80:80"- "443:443"@@ -17,10 +14,7 @@ services:restart: alwaysclient:- image: aliasvault-client- build:- context: .- dockerfile: src/AliasVault.Client/Dockerfile+ image: ghcr.io/lanedirt/aliasvault-client:latestvolumes:- ./logs/msbuild:/src/msbuild-logs:rwexpose:@@ -30,10 +24,7 @@ services:- .envapi:- image: aliasvault-api- build:- context: .- dockerfile: src/AliasVault.Api/Dockerfile+ image: ghcr.io/lanedirt/aliasvault-api:latestexpose:- "3001"volumes:@@ -45,10 +36,7 @@ services:restart: alwaysadmin:- image: aliasvault-admin- build:- context: .- dockerfile: src/AliasVault.Admin/Dockerfile+ image: ghcr.io/lanedirt/aliasvault-admin:latestexpose:- "3002"volumes:@@ -60,10 +48,7 @@ services:- .envsmtp:- image: aliasvault-smtp- build:- context: .- dockerfile: src/Services/AliasVault.SmtpService/Dockerfile+ image: ghcr.io/lanedirt/aliasvault-smtp:latestports:- "25:25"- "587:587"diff --git a/install.sh b/install.shindex 72ef220cd..8d814a45f 100755--- a/install.sh+++ b/install.sh@@ -1,363 +1,24 @@-#!/bin/sh+#!/bin/bash-# Define colors for CLI output-RED='\033[0;31m'-GREEN='\033[0;32m'-YELLOW='\033[0;33m'-BLUE='\033[0;34m'-MAGENTA='\033[0;35m'-CYAN='\033[0;36m'-NC='\033[0m' # No Color+# Import common functions from common.sh+source common.sh-# Define the path to the .env and .env.example files-ENV_FILE=".env"-ENV_EXAMPLE_FILE=".env.example"--# Define verbose flag and reset password flag-VERBOSE=false-RESET_PASSWORD=false--# Function to parse command-line arguments-parse_args() {- while [ $# -gt 0 ]; do- case "$1" in- --verbose)- VERBOSE=true- ;;- --reset-password)- RESET_PASSWORD=true- ;;- *)- printf "${RED}Unknown argument: $1${NC}\n"- exit 1- ;;- esac- shift- done-}--# Function to generate a random admin password and store its hash in the .env file-generate_admin_password() {- if grep -q "^ADMIN_PASSWORD_HASH=" ".env" && [ "$RESET_PASSWORD" = false ]; then- printf "${CYAN}> Checking admin password...${NC}\n"- printf "${GREEN}> ADMIN_PASSWORD_HASH already exists in .env. Use --reset-password to generate a new one.${NC}\n"- return 0- fi-- printf "${CYAN}> Generating new admin password...${NC}\n"-- ADMIN_PASSWORD=$(openssl rand -base64 12)- printf "${CYAN}> Building Docker image for password generation...${NC}"-- if [ "$VERBOSE" = true ]; then- printf "\n"- docker build -t initcli -f src/Utilities/AliasVault.InstallCli/Dockerfile .- else- (- # Run docker build and capture its output- docker build -t initcli -f src/Utilities/AliasVault.InstallCli/Dockerfile . > install_build_output.log 2>&1 &- BUILD_PID=$!-- printf "${CYAN}"-- # Print dots while the build is running- while kill -0 $BUILD_PID 2>/dev/null; do- printf "."- sleep 1- done-- printf "${NC}\n"-- # Wait for the build to finish and capture its exit code- wait $BUILD_PID- BUILD_EXIT_CODE=$?-- # If there was an error, display it- if [ $BUILD_EXIT_CODE -ne 0 ]; then- printf "\n${RED} An error occurred while building the Docker image for password generation. Check the output above.${NC}\n"- printf "\n"- cat install_build_output.log- exit $BUILD_EXIT_CODE- fi- )- fi-- printf "${GREEN}> Docker image built successfully.${NC}\n"-- printf "${CYAN}> Running Docker container to generate admin password hash...${NC}\n"-- # Run the Docker container to generate the password hash- ADMIN_PASSWORD_HASH=$(docker run --rm initcli "$ADMIN_PASSWORD" 2> install_run_output.log)- RUN_EXIT_CODE=$?-- if [ $RUN_EXIT_CODE -ne 0 ]; then- printf "${RED}> Error occurred while running the Docker container. Check install_run_output.log for details.${NC}\n"- return $RUN_EXIT_CODE- fi-- # Remove existing ADMIN_PASSWORD_HASH and ADMIN_PASSWORD_GENERATED if it exists- sed -i '' '/^ADMIN_PASSWORD_HASH=/d' .env- sed -i '' '/^ADMIN_PASSWORD_GENERATED=/d' .env-- # Append new entries- echo "ADMIN_PASSWORD_HASH=$ADMIN_PASSWORD_HASH" >> .env- echo "ADMIN_PASSWORD_GENERATED=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> .env-- printf "${GREEN}> New admin password generated and hash stored in .env${NC}\n"-}--# Function to restart Docker containers-restart_docker_containers() {- printf "${CYAN}> Restarting Docker containers...${NC}\n"- docker compose down- docker compose up -d- printf "${GREEN}> Docker containers restarted successfully.${NC}\n"-}--# Function to generate a new 32-character JWT key-generate_jwt_key() {- dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | head -c 32-}--# Function to generate a new 60-character DATA_PROTECTION_CERT_PASS-generate_data_protection_cert_pass() {- dd if=/dev/urandom bs=1 count=60 2>/dev/null | base64 | head -c 60-}--# Function to create .env file from .env.example if it doesn't exist-create_env_file() {- printf "${CYAN}> Creating .env file...${NC}\n"- if [ ! -f "$ENV_FILE" ]; then- if [ -f "$ENV_EXAMPLE_FILE" ]; then- cp "$ENV_EXAMPLE_FILE" "$ENV_FILE"- printf "${GREEN}> .env file created from .env.example.${NC}\n"- else- touch "$ENV_FILE"- printf "${YELLOW}> .env file created as empty because .env.example was not found.${NC}\n"- fi- else- printf "${GREEN}> .env file already exists.${NC}\n"- fi-}--# Function to populate HOSTNAME-populate_hostname() {- printf "${CYAN}> Checking HOSTNAME...${NC}\n"- if ! grep -q "^HOSTNAME=" "$ENV_FILE" || [ -z "$(grep "^HOSTNAME=" "$ENV_FILE" | cut -d '=' -f2)" ]; then- DEFAULT_HOSTNAME="localhost"- read -p "Enter the hostname where AliasVault will be hosted (press Enter for default: $DEFAULT_HOSTNAME): " USER_HOSTNAME- HOSTNAME=${USER_HOSTNAME:-$DEFAULT_HOSTNAME}- if grep -q "^HOSTNAME=" "$ENV_FILE"; then- awk -v hostname="$HOSTNAME" '/^HOSTNAME=/ {$0="HOSTNAME="hostname} 1' "$ENV_FILE" > "$ENV_FILE.tmp" && mv "$ENV_FILE.tmp" "$ENV_FILE"- else- echo "HOSTNAME=${HOSTNAME}" >> "$ENV_FILE"- fi- printf "${GREEN}> HOSTNAME has been set to $HOSTNAME in $ENV_FILE.${NC}\n"- else- HOSTNAME=$(grep "^HOSTNAME=" "$ENV_FILE" | cut -d '=' -f2)- printf "${GREEN}> HOSTNAME already exists in $ENV_FILE with value: $HOSTNAME${NC}\n"- fi-}--# Function to check and populate the .env file with JWT_KEY-populate_jwt_key() {- printf "${CYAN}> Checking JWT_KEY...${NC}\n"- if ! grep -q "^JWT_KEY=" "$ENV_FILE" || [ -z "$(grep "^JWT_KEY=" "$ENV_FILE" | cut -d '=' -f2)" ]; then- JWT_KEY=$(generate_jwt_key)- if grep -q "^JWT_KEY=" "$ENV_FILE"; then- awk -v key="$JWT_KEY" '/^JWT_KEY=/ {$0="JWT_KEY="key} 1' "$ENV_FILE" > "$ENV_FILE.tmp" && mv "$ENV_FILE.tmp" "$ENV_FILE"- else- echo "JWT_KEY=${JWT_KEY}" >> "$ENV_FILE"- fi- printf "${GREEN}> JWT_KEY has been generated and added to $ENV_FILE.${NC}\n"- else- printf "${GREEN}> JWT_KEY already exists and has a value in $ENV_FILE.${NC}\n"- fi-}--# Function to check and populate the .env file with DATA_PROTECTION_CERT_PASS-populate_data_protection_cert_pass() {- printf "${CYAN}> Checking DATA_PROTECTION_CERT_PASS...${NC}\n"- if ! grep -q "^DATA_PROTECTION_CERT_PASS=" "$ENV_FILE" || [ -z "$(grep "^DATA_PROTECTION_CERT_PASS=" "$ENV_FILE" | cut -d '=' -f2)" ]; then- DATA_PROTECTION_CERT_PASS=$(generate_data_protection_cert_pass)- if grep -q "^DATA_PROTECTION_CERT_PASS=" "$ENV_FILE"; then- awk -v key="DATA_PROTECTION_CERT_PASS" '/^DATA_PROTECTION_CERT_PASS=/ {$0="DATA_PROTECTION_CERT_PASS="key} 1' "$ENV_FILE" > "$ENV_FILE.tmp" && mv "$ENV_FILE.tmp" "$ENV_FILE"- else- echo "DATA_PROTECTION_CERT_PASS=${DATA_PROTECTION_CERT_PASS}" >> "$ENV_FILE"- fi- printf "${GREEN}> DATA_PROTECTION_CERT_PASS has been generated and added to $ENV_FILE.${NC}\n"- else- printf "${GREEN}> DATA_PROTECTION_CERT_PASS already exists and has a value in $ENV_FILE.${NC}\n"- fi-}--# Function to ask the user for PRIVATE_EMAIL_DOMAINS-set_private_email_domains() {- printf "${CYAN}> Setting PRIVATE_EMAIL_DOMAINS...${NC}\n"- if ! grep -q "^PRIVATE_EMAIL_DOMAINS=" "$ENV_FILE" || [ -z "$(grep "^PRIVATE_EMAIL_DOMAINS=" "$ENV_FILE" | cut -d '=' -f2)" ]; then- printf "Please enter the domains that should be allowed to receive email, separated by commas (press Enter to disable email support): "- read -r private_email_domains-- # Set default value if user input is empty- private_email_domains=${private_email_domains:-"DISABLED.TLD"}-- if grep -q "^PRIVATE_EMAIL_DOMAINS=" "$ENV_FILE"; then- awk -v domains="$private_email_domains" '/^PRIVATE_EMAIL_DOMAINS=/ {$0="PRIVATE_EMAIL_DOMAINS="domains} 1' "$ENV_FILE" > "$ENV_FILE.tmp" && mv "$ENV_FILE.tmp" "$ENV_FILE"- else- echo "PRIVATE_EMAIL_DOMAINS=${private_email_domains}" >> "$ENV_FILE"- fi-- if [ "$private_email_domains" = "DISABLED.TLD" ]; then- printf "${GREEN}> PRIVATE_EMAIL_DOMAINS has been set to 'DISABLED.TLD' in $ENV_FILE.${NC} ${RED}SMTP is disabled.${NC}\n"- else- printf "${GREEN}> PRIVATE_EMAIL_DOMAINS has been set to '${private_email_domains}' in $ENV_FILE.${NC}\n"- fi- else- private_email_domains=$(grep "^private_email_domains=" "$ENV_FILE" | cut -d '=' -f2)- if [ "$private_email_domains" = "DISABLED.TLD" ]; then- printf "${GREEN}> PRIVATE_EMAIL_DOMAINS already exists in $ENV_FILE.${NC} ${RED}SMTP is disabled.${NC}\n"- else- printf "${GREEN}> PRIVATE_EMAIL_DOMAINS already exists in $ENV_FILE with value: ${private_email_domains}${NC}\n"- fi- fi-}--# Function to ask the user if TLS should be enabled for email-set_smtp_tls_enabled() {- printf "${CYAN}> Setting SMTP_TLS_ENABLED...${NC}\n"- if ! grep -q "^SMTP_TLS_ENABLED=" "$ENV_FILE" || [ -z "$(grep "^SMTP_TLS_ENABLED=" "$ENV_FILE" | cut -d '=' -f2)" ]; then- printf "Do you want TLS enabled for email? (yes/no): "- read -r tls_enabled- tls_enabled=$(echo "$tls_enabled" | tr '[:upper:]' '[:lower:]')- if [ "$tls_enabled" = "yes" ] || [ "$tls_enabled" = "y" ]; then- tls_enabled="true"- else- tls_enabled="false"- fi- if grep -q "^SMTP_TLS_ENABLED=" "$ENV_FILE"; then- awk -v tls="$tls_enabled" '/^SMTP_TLS_ENABLED=/ {$0="SMTP_TLS_ENABLED="tls} 1' "$ENV_FILE" > "$ENV_FILE.tmp" && mv "$ENV_FILE.tmp" "$ENV_FILE"- else- echo "SMTP_TLS_ENABLED=${tls_enabled}" >> "$ENV_FILE"- fi- printf "${GREEN}> SMTP_TLS_ENABLED has been set to ${tls_enabled} in $ENV_FILE.${NC}\n"- else- printf "${GREEN}> SMTP_TLS_ENABLED already exists and has a value in $ENV_FILE.${NC}\n"- fi-}--# Function to ask for support email-set_support_email() {- printf "${CYAN}> Setting SUPPORT_EMAIL...${NC}\n"- if ! grep -q "^SUPPORT_EMAIL=" "$ENV_FILE"; then- printf "Please enter the support email address that users can contact for issues accessing their vault (press Enter to disable): "- read -r support_email-- echo "SUPPORT_EMAIL=${support_email}" >> "$ENV_FILE"-- if [ -z "$support_email" ]; then- printf "${GREEN}> SUPPORT_EMAIL has been left empty in $ENV_FILE.${NC}\n"- else- printf "${GREEN}> SUPPORT_EMAIL has been set to '${support_email}' in $ENV_FILE.${NC}\n"- fi- else- support_email=$(grep "^SUPPORT_EMAIL=" "$ENV_FILE" | cut -d '=' -f2)- if [ -z "$support_email" ]; then- printf "${GREEN}> SUPPORT_EMAIL already exists in $ENV_FILE but is empty.${NC}\n"- else- printf "${GREEN}> SUPPORT_EMAIL already exists in $ENV_FILE with value: ${support_email}${NC}\n"- fi- fi-}--# Function to build and run the Docker Compose stack with muted output unless an error occurs, showing progress indication-build_and_run_docker_compose() {- printf "${CYAN}> Building Docker Compose stack..."- if [ "$VERBOSE" = true ]; then- docker compose build- else- (- # Run docker compose build and capture its output- docker compose build > install_compose_build_output.log 2>&1 &- BUILD_PID=$!-- # Print dots while the build is running- while kill -0 $BUILD_PID 2>/dev/null; do- printf "."- sleep 1- done-- printf "${NC}"-- # Wait for the build to finish and capture its exit code- wait $BUILD_PID- BUILD_EXIT_CODE=$?-- # If there was an error, display it- if [ $BUILD_EXIT_CODE -ne 0 ]; then- printf "\n${RED}> An error occurred while building the Docker Compose stack. Check install_compose_build_output.log for details.${NC}\n"- exit $BUILD_EXIT_CODE- fi- )- fi-- printf "\n${GREEN}> Docker Compose stack built successfully.${NC}\n"-- printf "${CYAN}> Starting Docker Compose stack...${NC}\n"- if [ "$VERBOSE" = true ]; then- docker compose up -d- else- docker compose up -d > install_compose_up_output.log 2>&1- fi- UP_EXIT_CODE=$?-- if [ $UP_EXIT_CODE -ne 0 ]; then- printf "${RED}> An error occurred while starting the Docker Compose stack. Check install_compose_up_output.log for details.${NC}\n"- exit $UP_EXIT_CODE- fi-- printf "${GREEN}> Docker Compose stack started successfully.${NC}\n"-}--# Function to print the CLI logo-print_logo() {- printf "${MAGENTA}\n"- printf "=========================================================\n"- printf " _ _ __ __ _ _ \n"- printf " /\ | (_) \ \ / / | | | \n"- printf " / \ | |_ __ _ __\ \ / /_ _ _ _| | |_\n"- printf " / /\ \ | | |/ _ / __\ \/ / _ | | | | | __|\n"- printf " / ____ \| | | (_| \__ \\ / (_| | |_| | | |_ \n"- printf " /_/ \_\_|_|\__,_|___/ \/ \__,_|\__,_|_|\__|\n"- printf "\n"- printf " Install Script\n"- printf "=========================================================\n"- printf "${NC}\n"-}--# Main execution flow+# Main functionmain() {parse_args "$@"+ print_logoif [ "$RESET_PASSWORD" = true ]; then- print_logogenerate_admin_passwordif [ $? -eq 0 ]; thenrestart_docker_containers+ print_password_reset_messagefi-- printf "\n"- printf "${MAGENTA}=========================================================${NC}\n"- printf "\n"- printf "${GREEN}The admin password is successfully reset!${NC}\n"- printf "\n"- printf "${MAGENTA}=========================================================${NC}\n"- printf "\n"else- # Run the original initialization process- print_logo-- printf "${YELLOW}+++ Initializing .env file +++${NC}\n"+ printf "${YELLOW}+++ Installing AliasVault +++${NC}\n"printf "\n"++ # Initialize environmentcreate_env_file || exit $?populate_hostname || exit $?populate_jwt_key || exit $?@@ -365,41 +26,36 @@ main() {set_private_email_domains || exit $?set_smtp_tls_enabled || exit $?set_support_email || exit $?- generate_admin_password || exit $?- printf "\n${YELLOW}+++ Building Docker containers +++${NC}\n"- printf "\n"- build_and_run_docker_compose || exit $?- printf "\n"- printf "${MAGENTA}=========================================================${NC}\n"- printf "\n"- printf "${GREEN}AliasVault is successfully installed!${NC}\n"++ # Only generate admin password if not already set+ if ! grep -q "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" || [ -z "$(grep "^ADMIN_PASSWORD_HASH=" "$ENV_FILE" | cut -d '=' -f2)" ]; then+ generate_admin_password || exit $?+ fi++ # Pull images from GitHub Container Registry+ printf "\n${YELLOW}+++ Pulling Docker images +++${NC}\n"printf "\n"- printf "${MAGENTA}=========================================================${NC}\n"++ images=(+ "ghcr.io/lanedirt/aliasvault-reverse-proxy:latest"+ "ghcr.io/lanedirt/aliasvault-api:latest"+ "ghcr.io/lanedirt/aliasvault-client:latest"+ "ghcr.io/lanedirt/aliasvault-admin:latest"+ "ghcr.io/lanedirt/aliasvault-smtp:latest"+ )++ for image in "${images[@]}"; do+ printf "${CYAN}> Pulling $image...${NC}\n"+ docker pull $image+ done++ # Start containers+ printf "\n${YELLOW}+++ Starting services +++${NC}\n"printf "\n"- fi+ docker compose up -d- printf "${CYAN}To configure the server, login to the admin panel:${NC}\n"- printf "\n"- if [ "$ADMIN_PASSWORD" != "" ]; then- printf "Admin Panel: https://$HOSTNAME/admin\n"- printf "Username: admin\n"- printf "Password: $ADMIN_PASSWORD\n"- printf "\n"- printf "${YELLOW}(!) Caution: Make sure to backup the above credentials in a safe place, they won't be shown again!${NC}\n"- printf "\n"- else- printf "Admin Panel: https://$HOSTNAME/admin\n"- printf "Username: admin\n"- printf "Password: (Previously set. Run this command with --reset-password to generate a new one.)\n"- printf "\n"+ print_success_messagefi- printf "${CYAN}===========================${NC}\n"- printf "\n"- printf "${CYAN}In order to start using AliasVault and create your own vault, log into the client website:${NC}\n"- printf "\n"- printf "Client Website: https://$HOSTNAME/\n"- printf "\n"- printf "${MAGENTA}=========================================================${NC}\n"}# Run the main functiondiff --git a/uninstall.sh b/uninstall.shindex ab5015768..2acaece76 100755--- a/uninstall.sh+++ b/uninstall.sh@@ -1,56 +1,15 @@-#!/bin/sh+#!/bin/bash-# Define colors for CLI output-RED='\033[0;31m'-GREEN='\033[0;32m'-YELLOW='\033[0;33m'-BLUE='\033[0;34m'-MAGENTA='\033[0;35m'-CYAN='\033[0;36m'-NC='\033[0m' # No Color--# Define verbose flag-VERBOSE=false--# Function to parse command-line arguments-parse_args() {- while [ $# -gt 0 ]; do- case "$1" in- --verbose)- VERBOSE=true- ;;- *)- printf "${RED}Unknown argument: $1${NC}\n"- exit 1- ;;- esac- shift- done-}--# Function to print the CLI logo-print_logo() {- printf "${MAGENTA}\n"- printf "=========================================================\n"- printf " _ _ __ __ _ _ \n"- printf " /\ | (_) \ \ / / | | | \n"- printf " / \ | |_ __ _ __\ \ / /_ _ _ _| | |_\n"- printf " / /\ \ | | |/ _ / __\ \/ / _ | | | | | __|\n"- printf " / ____ \| | | (_| \__ \\ / (_| | |_| | | |_ \n"- printf " /_/ \_\_|_|\__,_|___/ \/ \__,_|\__,_|_|\__|\n"- printf "\n"- printf " Uninstall Script\n"- printf "=========================================================\n"- printf "${NC}\n"-}+# Import common functions+source common.sh# Function to stop and remove Docker containersstop_and_remove_containers() {printf "${CYAN}> Stopping and removing Docker containers...${NC}\n"if [ "$VERBOSE" = true ]; then- docker compose down -v+ docker compose -f docker-compose.yml -f docker-compose.build.yml down -velse- docker compose down -v > /dev/null 2>&1+ docker compose -f docker-compose.yml -f docker-compose.build.yml down -v > /dev/null 2>&1fiprintf "${GREEN}> Docker containers stopped and removed.${NC}\n"}@@ -59,9 +18,9 @@ stop_and_remove_containers() {remove_docker_images() {printf "${CYAN}> Removing Docker images...${NC}\n"if [ "$VERBOSE" = true ]; then- docker compose down --rmi all+ docker compose -f docker-compose.yml -f docker-compose.build.yml down --rmi allelse- docker compose down --rmi all > /dev/null 2>&1+ docker compose -f docker-compose.yml -f docker-compose.build.yml down --rmi all > /dev/null 2>&1fiprintf "${GREEN}> Docker images removed.${NC}\n"}