diff --git a/install.sh b/install.sh index 21a2a7e..b2b8641 100755 --- a/install.sh +++ b/install.sh @@ -1,9 +1,9 @@ #!/usr/bin/bash -working_dir=~/.local/share/catask +working_dir=$PWD/catask bold=$(tput bold) normal=$(tput sgr0) -git_repo_url="https://git.mst.k.vu/mst/catask" +git_repo_url="https://git.mst.k.vu/catask-org/catask" git_repo_issue_url="${git_repo_url}/issues/new" echo "--------------------------" @@ -12,9 +12,9 @@ echo "--------------------------" echo echo "${bold}Cloning the repository...${normal}" # this might work... or not, who knows -id -u catask >/dev/null 2>&1 || sudo useradd -r -s /bin/false -m -d /etc/catask -U catask +# id -u catask >/dev/null 2>&1 || sudo useradd -r -s /bin/false -m -d $working_dir/home/catask -U catask # cloning dev branch for now because the installer doesn't exist in main branch yet -sudo git clone $git_repo_url $working_dir --branch dev +git clone $git_repo_url $working_dir cd $working_dir echo echo "${bold}Creating & activating virtual environment...${normal}" @@ -64,10 +64,16 @@ echo echo "${bold}Configuring CatAsk...${normal}" cp $working_dir/.env.example $working_dir/.env; cp $working_dir/config.example.json $working_dir/config.json echo +if ! command -v $EDITOR 2>&1 >/dev/null; then + echo "No default editor found, falling back to ${bold}nano${normal}..." + editor_=nano +else + editor_=$EDITOR +fi read -n 1 -s -r -p "Press any key to open main config file..." -nano config.json +$editor_ config.json read -n 1 -s -r -p "Press any key to open .env config file..." -nano .env +$editor_ .env echo echo "${bold}Initializing the database...${normal}" @@ -89,17 +95,20 @@ if [[ "${sysd_service_input,,}" == 'n' ]]; then 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 + 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 + [Service] + User=%u + WorkingDirectory=$working_dir + ExecStart=$working_dir/venv/bin/python3 -m gunicorn -w 4 app:app -b $catask_addr + + [Install] + WantedBy=multi-user.target + EOF fi echo "Created a systemd service with these contents:" echo "-----------------------"