Skip to content

Commit

Permalink
Merge pull request #335 from CooperGerman/master
Browse files Browse the repository at this point in the history
Create install_arch.sh
  • Loading branch information
Donkie authored May 4, 2024
2 parents 3db0271 + a6774dd commit 1ddd9fb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,4 @@ $RECYCLE.BIN/

data/
.pdm-python
.history
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mkdir -p ./Spoolman && \
source_url=$(curl -s https://api.github.com/repos/Donkie/Spoolman/releases/latest | jq -r '.assets[] | select(.name == "spoolman.zip").browser_download_url') && \
curl -sSL $source_url -o temp.zip && unzip temp.zip -d ./Spoolman && rm temp.zip && \
cd ./Spoolman && \
bash ./scripts/install_debian.sh
bash ./scripts/install.sh
```

#### Updating
Expand All @@ -77,7 +77,7 @@ source_url=$(curl -s https://api.github.com/repos/Donkie/Spoolman/releases/lates
curl -sSL $source_url -o temp.zip && unzip temp.zip -d ./Spoolman && rm temp.zip && \
cp Spoolman_old/.env Spoolman/.env && \
cd ./Spoolman && \
bash ./scripts/install_debian.sh && \
bash ./scripts/install.sh && \
rm -rf ../Spoolman_old
```

Expand Down
68 changes: 49 additions & 19 deletions scripts/install_debian.sh → scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,65 @@ else
echo -e "${ORANGE}Please look up how to install Python 3.9 or later for your specific operating system.${NC}"
exit 1
fi

#
# Install needed system packages
# Get os package manager
#
# Run apt-get update
echo -e "${GREEN}Updating apt-get cache...${NC}"
sudo apt-get update || exit 1
if [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ "$ID_LIKE" == *"debian"* || "$ID" == *"debian"* ]]; then
pkg_manager="apt-get"
update_cmd="sudo $pkg_manager update"
install_cmd="sudo $pkg_manager install -y"
echo -e "${GREEN}Detected Debian-based system. Using apt-get package manager.${NC}"
elif [[ "$ID_LIKE" == *"arch"* || "$ID" == *"arch"* ]]; then
pkg_manager="pacman"
update_cmd="sudo $pkg_manager -Sy"
install_cmd="sudo $pkg_manager -S --noconfirm"
echo -e "${GREEN}Detected Arch-based system. Using pacman package manager.${NC}"
else
echo -e "${ORANGE}Your operating system is not supported. Either try to install manually or reach out to spoolman github for support.${NC}"
exit 1
fi
fi

install_packages=0
# Run pkg manager update
echo -e "${GREEN}Updating $pkg_manager cache...${NC}"
$update_cmd || exit 1
packages=""
if ! python3 -c 'import venv, ensurepip' &>/dev/null; then
echo -e "${ORANGE}Python venv module is not accessible. Installing venv...${NC}"
install_packages=1
if [[ "$pkg_manager" == "apt-get" ]]; then
packages+=" python3-venv"
elif [[ "$pkg_manager" == "pacman" ]]; then
packages+=" python-virtualenv"
fi
fi

if ! command -v pip3 &>/dev/null; then
echo -e "${ORANGE}Python pip is not installed. Installing pip...${NC}"
install_packages=1
if [[ "$pkg_manager" == "apt-get" ]]; then
packages+=" python3-pip"
elif [[ "$pkg_manager" == "pacman" ]]; then
packages+=" python-pip"
fi
fi

if ! command -v pg_config &>/dev/null; then
echo -e "${ORANGE}pg_config is not available. Installing libpq-dev...${NC}"
install_packages=1
if [[ "$pkg_manager" == "apt-get" ]]; then
packages+=" libpq-dev"
elif [[ "$pkg_manager" == "pacman" ]]; then
packages+=" postgresql-libs"
fi
fi

if ! command -v unzip &>/dev/null; then
echo -e "${ORANGE}unzip is not available. Installing unzip...${NC}"
install_packages=1
packages+=" unzip"
fi

if [ "$install_packages" -eq 1 ]; then
# sudo apt-get update
sudo apt-get install -y python3-pip python3-venv libpq-dev unzip || exit 1
if [[ -n "$packages" ]]; then
$install_cmd $packages || exit 1
fi

#
Expand Down Expand Up @@ -114,11 +141,15 @@ fi
echo -e "${GREEN}Installing system-wide pip packages needed for Spoolman...${NC}"
if [[ $is_externally_managed_env ]]; then
echo -e "${GREEN}Installing the packages using apt-get instead of pip since pip is externally managed...${NC}"
apt_packages=("python3-setuptools" "python3-wheel")
sudo apt-get install -y "${apt_packages[@]}" || exit 1
if [[ "$pkg_manager" == "apt-get" ]]; then
packages="python3-setuptools python3-wheel"
elif [[ "$pkg_manager" == "pacman" ]]; then
packages="python-setuptools python-wheel"
fi
$install_cmd $packages || exit 1
else
packages=("setuptools" "wheel")
for package in "${packages[@]}"; do
packages="setuptools wheel"
for package in $packages; do
if ! pip3 show "$package" &>/dev/null; then
echo -e "${GREEN}Installing $package...${NC}"
pip3 install --user "$package" || exit 1
Expand All @@ -138,9 +169,8 @@ fi
# Install Spoolman
#

# Install PDM dependencies
# Install dependencies
echo -e "${GREEN}Installing Spoolman backend and its dependencies...${NC}"

# Create venv if it doesn't exist
if [ ! -d ".venv" ]; then
python3 -m venv .venv || exit 1
Expand Down

0 comments on commit 1ddd9fb

Please sign in to comment.