Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single command installation script #223

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions frappe_manager/docker_wrapper/DockerClient.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import json
import shlex
from sys import exception

from typing import Literal, Optional, List
from pathlib import Path
from frappe_manager.docker_wrapper.DockerCompose import DockerComposeWrapper
from frappe_manager.display_manager.DisplayManager import richprint
from frappe_manager.docker_wrapper.DockerException import DockerException
from frappe_manager.utils.docker import (
SubprocessOutput,
Expand Down
5 changes: 2 additions & 3 deletions frappe_manager/ssl_manager/letsencrypt_certificate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, List, Self
from typing import Optional, List
from pydantic import EmailStr, Field, model_validator
from frappe_manager.ssl_manager import LETSENCRYPT_PREFERRED_CHALLENGE
from frappe_manager.ssl_manager.certificate import SSLCertificate
Expand All @@ -14,13 +14,12 @@ class LetsencryptSSLCertificate(SSLCertificate):
toml_exclude: Optional[set] = {'domain', 'alias_domains', 'toml_exclude'}

@model_validator(mode="after")
def validate_credentials(self) -> Self:
def validate_credentials(self):
if self.preferred_challenge == LETSENCRYPT_PREFERRED_CHALLENGE.dns01:
if self.api_key or self.api_token:
return self
else:
raise SSLDNSChallengeCredentailsNotFound()

return self

def get_cloudflare_dns_credentials(self) -> str:
Expand Down
29 changes: 14 additions & 15 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
PS4='+\[\033[0;33m\](\[\033[0;36m\]${BASH_SOURCE##*/}:${LINENO}\[\033[0;33m\])\[\033[0m\] '
LOGFILE="fm-install-$(date +"%Y%m%d_%H%M%S").log"

exec {BASH_XTRACEFD}>>"$LOGFILE"
set -xe

print_in_color() {
Expand Down Expand Up @@ -41,13 +43,18 @@ info_red(){

isRoot() {
if [ "$(id -u)" -eq 0 ]; then
info_red "You are running as root."
exit 69
info_red "This script is being run as the root user. Frappe-Manager supports installation only as a non-root user. Please switch to a non-root user and re-run this script."
exit 1
fi
}

install_fm(){
info_blue "Installing frappe-manager..."
pip3 install --user --upgrade --break-system-packages frappe-manager
info_green "$(bold 'fm' $(pip3 list | grep frappe-manager | awk '{print $2}')) installed."
}

has_docker_compose(){
declare desc="return 0 if we have docker compose command"
if [[ "$(dockexr compose version 2>&1 || true)" = *"docker: 'compose' is not a docker command."* ]]; then
return 1
else
Expand All @@ -56,7 +63,6 @@ has_docker_compose(){
}

has_pyenv(){
declare desc="return 0 if we have docker compose command"
if [[ "$(pyenv --version 2>&1 || true)" = *"pyenv: command not found"* ]]; then
return 1
else
Expand All @@ -65,13 +71,13 @@ has_pyenv(){
}

has_tty() {
declare desc="return 0 if we have a tty"
if [[ "$(/usr/bin/tty || true)" == "not a tty" ]]; then
return 1
else
return 0
fi
}

if has_tty; then
if ! [[ "${INTERACTIVE:-}" ]]; then
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -126,11 +132,8 @@ install_docker_ubuntu() {
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo DEBIAN_FRONTEND=noninteractive apt-get update

sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin

info_green "Docker Engine installed"
fi

Expand Down Expand Up @@ -215,9 +218,7 @@ install_python_and_frappe_ubuntu() {
install_pyenv_python
fi

info_blue "Installing frappe-manager..."
pip3 install --user --upgrade frappe-manager
info_green "$(bold 'fm' $(pip3 list | grep frappe-manager | awk '{print $2}')) installed."
install_fm
}

# Function to install Python and frappe-manager on macOS
Expand All @@ -232,7 +233,7 @@ install_python_and_frappe_macos() {
fi

if ! type pip3 > /dev/null 2>&1; then
info_blue "Using $(yellow 'brew') for installing pip3..."
info_blue "Installing pip3"
python -m ensurepip --upgrade
info_green "Installed pip3"
else
Expand All @@ -243,9 +244,7 @@ install_python_and_frappe_macos() {
install_pyenv_python
fi

info_blue "Installing frappe-manager..."
pip3 install --user --upgrade frappe-manager
info_green "$(bold 'fm' $(pip3 list | grep frappe-manager | awk '{print $2}')) installed."
install_fm
}

handle_shell(){
Expand Down