mirror of
https://codeberg.org/catask-org/catask.git
synced 2025-04-19 05:13:41 -05:00
86 lines
2.6 KiB
Bash
Executable file
86 lines
2.6 KiB
Bash
Executable file
#!/usr/bin/bash
|
|
|
|
# work in progress
|
|
id -u catask >/dev/null 2>&1 || sudo useradd -r -s /bin/false -m -d /etc/catask -U catask
|
|
# cloning branch dev for now because the installer doesn't exist in main branch yet
|
|
git clone https://git.gay/mst/catask ~/tmp/catask --branch dev
|
|
cd ~/tmp/catask
|
|
|
|
commit_short_hash=$(git rev-parse --short HEAD)
|
|
bold=$(tput bold)
|
|
normal=$(tput sgr0)
|
|
|
|
echo "--------------------------"
|
|
echo "${bold}Installing CatAsk (commit ${commit_short_hash})...${normal}"
|
|
echo "--------------------------"
|
|
echo
|
|
echo "${bold}Creating & activating virtual environment...${normal}"
|
|
python3 -m venv venv && . venv/bin/activate
|
|
echo
|
|
echo "${bold}Installing required packages...${normal}"
|
|
pip install -r requirements.txt
|
|
|
|
# move to /etc/catask after installing packages
|
|
sudo cp -r ~/tmp/catask/ /etc/catask/
|
|
|
|
echo
|
|
echo "${bold}Configuring CatAsk...${normal}"
|
|
cp .env.example .env; cp config.example.json config.json
|
|
echo
|
|
read -n 1 -s -r -p "Press any key to open main config file..."
|
|
nano config.json
|
|
read -n 1 -s -r -p "Press any key to open .env config file..."
|
|
nano .env
|
|
|
|
echo
|
|
echo 'Initializing the database...'
|
|
if flask init-db; then : ; else
|
|
echo 'If the error is "MySQL Connection not available." then you can safely ignore it'
|
|
echo 'Otherwise, create an issue at https://git.mst.k.vu/mst/catask/issues/new'
|
|
read -p "Proceed? (y/N) " proceed_after_error
|
|
proceed_after_error="${proceed_after_error,,}"
|
|
echo $proceed_after_error
|
|
if [[ "$proceed_after_error" == 'y' ]]; then
|
|
echo "Proceeding..."
|
|
else
|
|
exit 255
|
|
fi
|
|
fi
|
|
|
|
read -p "Do you want to install CatAsk as a systemd service? (Y/n) " sysd_service_input
|
|
|
|
if [[ "$sysd_service_input" == 'n' ]]; then
|
|
echo "Start CatAsk with: ${bold}gunicorn -w 4 app:app -b 127.0.0.1:5000${normal}"
|
|
echo "Replace ${bold}127.0.0.1:5000${normal} with address where CatAsk will run"
|
|
exit 0
|
|
else
|
|
read -p "Address on which CatAsk will run (127.0.0.1:5000): " catask_addr
|
|
catask_addr=${catask_addr:-127.0.0.1:5000}
|
|
sudo cat > /etc/systemd/system/catask.service << EOF
|
|
[Unit]
|
|
Description=catask
|
|
|
|
[Service]
|
|
User=catask
|
|
WorkingDirectory=$PWD
|
|
ExecStart=$PWD/venv/bin/python3 -m gunicorn -w 4 app:app -b $catask_addr
|
|
EOF
|
|
fi
|
|
echo "Created a systemd service with these contents:"
|
|
echo "-----------------------"
|
|
cat << EOF
|
|
[Unit]
|
|
Description=catask
|
|
|
|
[Service]
|
|
User=catask
|
|
WorkingDirectory=$PWD
|
|
ExecStart=$PWD/venv/bin/python3 -m gunicorn -w 4 app:app -b $catask_addr
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
echo "-----------------------"
|
|
echo "Start the service with: ${bold}sudo systemctl start --now catask${normal}"
|
|
echo
|
|
echo "${bold}Install complete!${normal}"
|