Update setup.sh

This commit is contained in:
Nick Sweeting 2024-02-18 05:21:27 -08:00 committed by GitHub
parent 968cd8f19c
commit e9f3b041ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,10 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# ArchiveBox Setup Script: https://github.com/ArchiveBox/ArchiveBox # ArchiveBox Setup Script (Ubuntu/Debian/FreeBSD/macOS)
# Supported Platforms: Ubuntu/Debian/FreeBSD/macOS # - Project Homepage: https://github.com/ArchiveBox/ArchiveBox
# Usage: # - Install Documentation: https://github.com/ArchiveBox/ArchiveBox/wiki/Install
# curl -sSL 'https://raw.githubusercontent.com/ArchiveBox/ArchiveBox/dev/bin/setup.sh' | sh # Script Usage:
# curl -fsSL 'https://raw.githubusercontent.com/ArchiveBox/ArchiveBox/dev/bin/setup.sh' | sh
# (aka https://docker-compose.archivebox.io)
clear clear
@ -20,19 +22,20 @@ fi
if (which docker-compose > /dev/null && docker pull archivebox/archivebox:latest); then if (which docker-compose > /dev/null && docker pull archivebox/archivebox:latest); then
echo "[+] Initializing an ArchiveBox data folder at ~/archivebox/data using Docker Compose..." echo "[+] Initializing an ArchiveBox data folder at ~/archivebox/data using Docker Compose..."
mkdir -p ~/archivebox mkdir -p ~/archivebox/data
cd ~/archivebox cd ~/archivebox
mkdir -p data
if [ -f "./index.sqlite3" ]; then if [ -f "./index.sqlite3" ]; then
mv ~/archivebox/* ~/archivebox/data/ mv -i ~/archivebox/* ~/archivebox/data/
fi fi
curl -O 'https://raw.githubusercontent.com/ArchiveBox/ArchiveBox/main/docker-compose.yml' curl -fsSL 'https://raw.githubusercontent.com/ArchiveBox/ArchiveBox/main/docker-compose.yml' > docker-compose.yml
mkdir -p ./etc
curl -fsSL 'https://raw.githubusercontent.com/ArchiveBox/ArchiveBox/main/etc/sonic.cfg' > ./etc/sonic.cfg
docker compose run --rm archivebox init --setup docker compose run --rm archivebox init --setup
echo echo
echo "[+] Starting ArchiveBox server using: docker compose up -d..." echo "[+] Starting ArchiveBox server using: docker compose up -d..."
docker compose up -d docker compose up -d
sleep 7 sleep 7
open http://127.0.0.1:8000 || true which open > /dev/null && open "http://127.0.0.1:8000" || true
echo echo
echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox/data. Usage:" echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox/data. Usage:"
echo " cd ~/archivebox" echo " cd ~/archivebox"
@ -46,21 +49,22 @@ if (which docker-compose > /dev/null && docker pull archivebox/archivebox:latest
echo " docker compose run archivebox help" echo " docker compose run archivebox help"
exit 0 exit 0
elif (which docker > /dev/null && docker pull archivebox/archivebox:latest); then elif (which docker > /dev/null && docker pull archivebox/archivebox:latest); then
echo "[+] Initializing an ArchiveBox data folder at ~/archivebox using Docker..." echo "[+] Initializing an ArchiveBox data folder at ~/archivebox/data using Docker..."
mkdir -p ~/archivebox mkdir -p ~/archivebox/data
cd ~/archivebox cd ~/archivebox
if [ -f "./data/index.sqlite3" ]; then if [ -f "./index.sqlite3" ]; then
cd ./data mv -i ~/archivebox/* ~/archivebox/data/
fi fi
cd ./data
docker run -v "$PWD":/data -it --rm archivebox/archivebox:latest init --setup docker run -v "$PWD":/data -it --rm archivebox/archivebox:latest init --setup
echo echo
echo "[+] Starting ArchiveBox server using: docker run -d archivebox/archivebox..." 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 docker run -v "$PWD":/data -it -d -p 8000:8000 --name=archivebox archivebox/archivebox:latest
sleep 7 sleep 7
open http://127.0.0.1:8000 || true which open > /dev/null && open "http://127.0.0.1:8000" || true
echo echo
echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox. Usage:" echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox/data. Usage:"
echo " cd ~/archivebox" echo " cd ~/archivebox/data"
echo " docker ps --filter name=archivebox" echo " docker ps --filter name=archivebox"
echo " docker kill archivebox" echo " docker kill archivebox"
echo " docker pull archivebox/archivebox" echo " docker pull archivebox/archivebox"
@ -115,22 +119,23 @@ if which apt-get > /dev/null; then
fi fi
echo echo
echo "[+] Installing ArchiveBox system dependencies using apt..." echo "[+] Installing ArchiveBox system dependencies using apt..."
sudo apt-get install -y git python3 python3-pip python3-distutils wget curl youtube-dl yt-dlp ffmpeg git nodejs npm ripgrep sudo apt-get install -y git python3 python3-pip python3-distutils wget curl yt-dlp ffmpeg git nodejs npm ripgrep
sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb libgbm-dev || sudo apt-get install -y chromium || sudo apt-get install -y chromium-browser || true sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb libgbm-dev || sudo apt-get install -y chromium || sudo apt-get install -y chromium-browser || true
sudo apt-get install -y archivebox sudo apt-get install -y archivebox
sudo apt-get --only-upgrade install -y archivebox sudo apt-get --only-upgrade install -y archivebox
echo "" echo ""
echo "[+] Installing ArchiveBox python dependencies using pip3..." echo "[+] Installing ArchiveBox python dependencies using pip3..."
sudo python3 -m pip install --upgrade --ignore-installed archivebox sudo python3 -m pip install --upgrade --ignore-installed archivebox yt-dlp playwright
# On Mac: # On Mac:
elif which brew > /dev/null; then elif which brew > /dev/null; then
echo "[+] Installing ArchiveBox system dependencies using brew..." echo "[+] Installing ArchiveBox system dependencies using brew..."
brew tap archivebox/archivebox brew tap archivebox/archivebox
brew update brew update
brew install python3 node git wget curl yt-dlp ripgrep
brew install --fetch-HEAD -f archivebox brew install --fetch-HEAD -f archivebox
echo "" echo ""
echo "[+] Installing ArchiveBox python dependencies using pip3..." echo "[+] Installing ArchiveBox python dependencies using pip3..."
python3 -m pip install --upgrade --ignore-installed archivebox python3 -m pip install --upgrade --ignore-installed archivebox yt-dlp playwright
elif which pkg > /dev/null; then elif which pkg > /dev/null; then
echo "[+] Installing ArchiveBox system dependencies using pkg and pip (python3.9)..." echo "[+] Installing ArchiveBox system dependencies using pkg and pip (python3.9)..."
sudo pkg install -y python3 py39-pip py39-sqlite3 npm wget curl youtube_dl ffmpeg git ripgrep sudo pkg install -y python3 py39-pip py39-sqlite3 npm wget curl youtube_dl ffmpeg git ripgrep
@ -138,7 +143,7 @@ elif which pkg > /dev/null; then
echo "" echo ""
echo "[+] Installing ArchiveBox python dependencies using pip..." echo "[+] Installing ArchiveBox python dependencies using pip..."
# don't use sudo here so that pip installs in $HOME/.local instead of into /usr/local # don't use sudo here so that pip installs in $HOME/.local instead of into /usr/local
python3 -m pip install --upgrade --ignore-installed archivebox python3 -m pip install --upgrade --ignore-installed archivebox yt-dlp playwright
else else
echo "[!] Warning: Could not find aptitude/homebrew/pkg! May not be able to install all dependencies automatically." echo "[!] Warning: Could not find aptitude/homebrew/pkg! May not be able to install all dependencies automatically."
echo "" echo ""
@ -173,23 +178,23 @@ fi
# sudo python3 -m pip install --upgrade pip setuptools || true # sudo python3 -m pip install --upgrade pip setuptools || true
echo echo
echo "[+] Initializing ArchiveBox data folder at ~/archivebox..." echo "[+] Initializing ArchiveBox data folder at ~/archivebox/data..."
mkdir -p ~/archivebox mkdir -p ~/archivebox/data
cd ~/archivebox cd ~/archivebox
if [ -f "./data/index.sqlite3" ]; then if [ -f "./index.sqlite3" ]; then
cd ./data mv -i ~/archivebox/* ~/archivebox/data/
fi fi
cd ./data
: | python3 -m archivebox init --setup || true # pipe in empty command to make sure stdin is closed : | python3 -m archivebox init --setup || true # pipe in empty command to make sure stdin is closed
echo echo
echo "[+] Starting ArchiveBox server using: nohup archivebox server &..." echo "[+] Starting ArchiveBox server using: nohup archivebox server &..."
nohup python3 -m archivebox server 0.0.0.0:8000 > ./logs/server.log 2>&1 & nohup python3 -m archivebox server 0.0.0.0:8000 > ./logs/server.log 2>&1 &
sleep 7 sleep 7
which open > /dev/null && open http://127.0.0.1:8000 || true which open > /dev/null && open "http://127.0.0.1:8000" || true
echo echo
echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox. Usage:" echo "[√] Server started on http://0.0.0.0:8000 and data directory initialized in ~/archivebox/data. Usage:"
echo " cd ~/archivebox # see your data dir" echo " cd ~/archivebox/data # see your data dir"
echo " ps aux | grep archivebox # see server process pid" echo " ps aux | grep archivebox # see server process pid"
echo " pkill -f archivebox # stop the server" echo " pkill -f archivebox # stop the server"
echo " archivebox server --quick-init 0.0.0.0:8000 # start server process" echo " archivebox server --quick-init 0.0.0.0:8000 # start server process"