1
0
Fork 0
mirror of synced 2024-06-01 18:20:20 +12:00
ArchiveBox/bin/setup.sh

168 lines
7.1 KiB
Bash
Raw Normal View History

2021-04-24 18:11:04 +12:00
#!/usr/bin/env sh
2021-04-24 15:49:44 +12:00
# ArchiveBox Setup Script: https://github.com/ArchiveBox/ArchiveBox
# Usage:
2021-04-24 18:11:04 +12:00
# curl 'https://raw.githubusercontent.com/ArchiveBox/ArchiveBox/dev/bin/setup.sh' | sh
clear
2018-06-11 13:58:48 +12:00
if (which docker-compose > /dev/null && docker pull archivebox/archivebox:latest); then
2021-04-24 16:06:07 +12:00
echo "[+] Initializing an ArchiveBox data folder at ~/archivebox/data using Docker Compose..."
mkdir -p ~/archivebox
cd ~/archivebox
mkdir -p data
2021-04-24 16:08:17 +12:00
if [ -f "./index.sqlite3" ]; then
2021-04-24 16:06:07 +12:00
mv ~/archivebox/* ~/archivebox/data/
fi
curl -O 'https://raw.githubusercontent.com/ArchiveBox/ArchiveBox/master/docker-compose.yml'
docker-compose run --rm archivebox init --setup
2021-04-24 16:55:51 +12:00
echo
echo "[+] Starting ArchiveBox server using: docker-compose up -d..."
2021-04-24 16:06:07 +12:00
docker-compose up -d
sleep 7
open http://127.0.0.1:8000 || true
2021-04-24 16:55:51 +12:00
echo
2021-04-24 16:23:14 +12:00
echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox/data. Usage:"
echo " cd ~/archivebox"
echo " docker-compose ps"
echo " docker-compose down"
echo " docker-compose pull"
echo " docker-compose up"
echo " docker-compose run archivebox manage createsuperuser"
2021-04-24 16:23:14 +12:00
echo " docker-compose run archivebox add 'https://example.com'"
echo " docker-compose run archivebox list"
echo " docker-compose run archivebox help"
2021-04-24 16:06:07 +12:00
exit 0
elif (which docker > /dev/null && docker pull archivebox/archivebox:latest); then
echo "[+] Initializing an ArchiveBox data folder at ~/archivebox using Docker..."
mkdir -p ~/archivebox
cd ~/archivebox
2021-04-24 16:08:17 +12:00
if [ -f "./data/index.sqlite3" ]; then
2021-04-24 16:06:07 +12:00
cd ./data
fi
docker run -v "$PWD":/data -it --rm archivebox/archivebox:latest init --setup
2021-04-24 16:55:51 +12:00
echo
echo "[+] Starting ArchiveBox server using: docker run -d archivebox/archivebox..."
docker run -v "$PWD":/data -it -d -p 8000:8000 --name=archivebox archivebox/archivebox:latest
2021-04-24 16:06:07 +12:00
sleep 7
open http://127.0.0.1:8000 || true
2021-04-24 16:55:51 +12:00
echo
2021-04-24 16:23:14 +12:00
echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox. Usage:"
echo " cd ~/archivebox"
echo " docker ps --filter name=archivebox"
echo " docker kill archivebox"
echo " docker pull archivebox/archivebox"
echo " docker run -v $PWD:/data -d -p 8000:8000 --name=archivebox archivebox/archivebox"
echo " docker run -v $PWD:/data -it archivebox/archivebox manage createsuperuser"
2021-04-24 16:23:14 +12:00
echo " docker run -v $PWD:/data -it archivebox/archivebox add 'https://example.com'"
echo " docker run -v $PWD:/data -it archivebox/archivebox list"
echo " docker run -v $PWD:/data -it archivebox/archivebox help"
exit 0
fi
2021-04-24 15:43:41 +12:00
echo ""
2021-04-24 17:02:12 +12:00
echo "[!] It's highly recommended to use ArchiveBox with Docker, but Docker wasn't found."
echo ""
echo " ⚠️ If you want to use Docker, press [Ctrl-C] to cancel now. ⚠️"
echo " Get Docker: https://docs.docker.com/get-docker/"
echo " (after you've installed Docker, run this script again)"
2021-04-24 16:50:05 +12:00
echo ""
2021-04-24 17:04:58 +12:00
echo "Otherwise, install will continue with apt/brew/pip in 15s... (press [Ctrl+C] to cancel)"
2021-04-24 17:02:12 +12:00
echo ""
2021-04-24 17:04:58 +12:00
sleep 15 || exit 1
2021-04-24 16:06:07 +12:00
2019-03-13 10:49:40 +13:00
echo "[i] ArchiveBox Setup Script 📦"
2018-06-11 13:58:48 +12:00
echo ""
2021-04-24 15:43:41 +12:00
echo " This is a helper script which installs the ArchiveBox dependencies on your system using brew/apt/pip3."
2021-04-24 16:55:51 +12:00
echo " You may be prompted for a sudo password in order to install the following:"
2019-03-13 10:49:40 +13:00
echo ""
echo " - archivebox"
echo " - python3, pip, nodejs, npm (languages used by ArchiveBox, and its extractor modules)"
2021-04-24 15:43:41 +12:00
echo " - curl, wget, git, youtube-dl (used for extracting title, favicon, git, media, and more)"
echo " - chromium (skips this if any Chrome/Chromium version is already installed)"
echo ""
2019-03-13 10:49:40 +13:00
echo ""
2021-04-24 15:43:41 +12:00
echo " If you'd rather install these manually as-needed, you can find detailed documentation here:"
2020-11-23 20:04:39 +13:00
echo " https://github.com/ArchiveBox/ArchiveBox/wiki/Install"
2018-06-11 13:58:48 +12:00
echo ""
2021-04-24 17:04:58 +12:00
echo "Continuing in 15s... (press [Ctrl+C] to cancel)"
echo ""
2021-04-24 17:04:58 +12:00
sleep 15 || exit 1
2018-06-11 13:58:48 +12:00
echo ""
# On Linux:
if which apt-get > /dev/null; then
2021-04-24 16:55:51 +12:00
echo "[+] Adding ArchiveBox apt repo and signing key to sources..."
2021-04-24 15:43:41 +12:00
if ! (sudo apt install -y software-properties-common && sudo add-apt-repository -u ppa:archivebox/archivebox); then
echo "deb http://ppa.launchpad.net/archivebox/archivebox/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/archivebox.list
echo "deb-src http://ppa.launchpad.net/archivebox/archivebox/ubuntu focal main" | sudo tee -a /etc/apt/sources.list.d/archivebox.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C258F79DCC02E369
sudo apt-get update -qq
2018-06-11 13:58:48 +12:00
fi
2021-04-24 16:55:51 +12:00
echo
2021-04-24 15:43:41 +12:00
echo "[+] Installing ArchiveBox and its dependencies using apt..."
# sudo apt install -y git python3 python3-pip python3-distutils wget curl youtube-dl ffmpeg git nodejs npm ripgrep
sudo apt-get install -y archivebox
sudo apt-get --only-upgrade install -y archivebox
2018-06-11 13:58:48 +12:00
# On Mac:
2021-04-24 15:43:41 +12:00
elif which brew > /dev/null; then
echo "[+] Installing ArchiveBox and its dependencies using brew..."
brew tap archivebox/archivebox
brew update
brew install --fetch-HEAD -f archivebox
2018-06-11 13:58:48 +12:00
else
echo "[!] Warning: Could not find aptitude or homebrew! May not be able to install all dependencies automatically."
2018-06-11 13:58:48 +12:00
echo ""
echo " If you're on macOS, make sure you have homebrew installed: https://brew.sh/"
2021-04-24 16:55:51 +12:00
echo " If you're on Linux, only Ubuntu/Debian systems are officially supported with this script."
echo " If you're on Windows, this script is not officially supported (Docker is recommeded instead)."
2018-06-11 13:58:48 +12:00
echo ""
2021-04-24 15:43:41 +12:00
echo "See the README.md for Manual Setup & Troubleshooting instructions if you you're unable to run ArchiveBox after this script completes."
2018-06-11 13:58:48 +12:00
fi
echo ""
if ! (python3 --version && python3 -m pip --version); then
echo "[X] Python 3 pip was not found on your system, you must first install Python >= 3.7."
echo " https://www.python.org/downloads/"
echo " https://wiki.python.org/moin/BeginnersGuide/Download"
echo " (after installing, run this script again)"
exit 1
fi
2021-04-24 15:43:41 +12:00
# echo "[+] Upgrading npm and pip..."
# npm i -g npm
# python3 -m pip install --upgrade pip setuptools
2021-01-23 07:41:16 +13:00
echo ""
2021-04-24 15:43:41 +12:00
echo "[+] Installing ArchiveBox and its dependencies using pip..."
python3 -m pip install --upgrade archivebox
2020-09-04 03:40:47 +12:00
2021-04-24 16:55:51 +12:00
echo
2021-04-24 15:43:41 +12:00
echo "[+] Initializing ArchiveBox data folder at ~/archivebox..."
mkdir -p ~/archivebox
cd ~/archivebox
2021-04-24 16:08:17 +12:00
if [ -f "./data/index.sqlite3" ]; then
2021-04-24 16:06:07 +12:00
cd ./data
fi
: | archivebox init --setup || true # pipe in empty command to make sure stdin is closed
2021-04-24 16:55:51 +12:00
echo
echo "[+] Starting ArchiveBox server using: nohup archivebox server &..."
nohup archivebox server 0.0.0.0:8000 > ./logs/server.log 2>&1 &
2021-04-24 16:23:14 +12:00
sleep 7
open http://127.0.0.1:8000 || true
2021-04-24 16:55:51 +12:00
echo
2021-04-24 16:23:14 +12:00
echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox. Usage:"
echo " cd ~/archivebox"
echo " ps aux | grep archivebox"
echo " pkill -f archivebox"
2021-04-24 16:23:14 +12:00
echo " pip3 install --upgrade archviebox"
echo " archivebox server --quick-init 0.0.0.0:8000"
echo " archivebox manage createsuperuser"
2021-04-24 16:23:14 +12:00
echo " archivebox add 'https://example.com'"
echo " archivebox list"
echo " archivebox help"