calibre-web - new seq for installation from pip and basic setup
This commit is contained in:
17
seqs/calibreweb.cfg.example
Normal file
17
seqs/calibreweb.cfg.example
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
CALWEB_BASE="/opt/calibre-web"
|
||||
CALWEB_VENV_ROOT="$CALWEB_BASE/venv"
|
||||
CALWEB_USER_HOME="$CALWEB_BASE/home"
|
||||
CALWEB_USER="calibreweb"
|
||||
CALWEB_SERVICE="[Unit]
|
||||
Description=Calibre-Web
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$CALWEB_USER
|
||||
ExecStart="$CALWEB_VENV_ROOT/bin/cps"
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target"
|
131
seqs/calibreweb.sh
Executable file
131
seqs/calibreweb.sh
Executable file
@@ -0,0 +1,131 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=calibre-web
|
||||
toolPipName=calibreweb
|
||||
toolDeps="python3-pip python3-venv"
|
||||
toolFeatures=( metadata comics )
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||
APTOPT=
|
||||
CONFIG=0
|
||||
SCRIPT_FILE=$(basename -- $0)
|
||||
SCRIPT_NAME=${SCRIPT_FILE%%.*}
|
||||
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
|
||||
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||
|
||||
step_config() {
|
||||
## or to use sequencer api with global config file:
|
||||
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
if [ $? -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
else
|
||||
# End if no configuration file exists
|
||||
[ $DRY -eq 0 ] && return -1
|
||||
fi
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
[ $QUIET -ne 0 ] && APTOPT="-y"
|
||||
|
||||
## Return of non zero value will abort the sequence
|
||||
return 0
|
||||
}
|
||||
|
||||
step_1_info() { echo "Install dependencies"; }
|
||||
step_1_alias() { ALIAS="install"; }
|
||||
step_1() {
|
||||
exe apt install $toolDeps $APTOPT
|
||||
}
|
||||
|
||||
step_2_info() { echo "Setup python virtual environment"; }
|
||||
step_2() {
|
||||
if ! id $CALWEB_USER &>/dev/null; then
|
||||
exe adduser --disabled-password --disabled-login --home-dir "$CALWEB_USER_HOME" --gecos "" $CALWEB_USER
|
||||
exe usermod -aG users $CALWEB_USER
|
||||
else
|
||||
echoseq " [W] User $CALWEB_USER already exists"
|
||||
fi
|
||||
if [ ! -e "$CALWEB_VENV_ROOT/bin" ]; then
|
||||
exe python3 -m venv "$CALWEB_VENV_ROOT"
|
||||
endReturn -o $? "Creating virtual environment failed"
|
||||
exe chown -R ${CALWEB_USER}: "$CALWEB_BASE"
|
||||
else
|
||||
echoseq " [W] Virtual env. $CALWEB_VENV_ROOT already exists"
|
||||
fi
|
||||
}
|
||||
|
||||
step_3_info() { echo "Install $toolName using pip"; }
|
||||
step_3() {
|
||||
step upgradepip
|
||||
exe ${CALWEB_VENV_ROOT}/bin/pip install $toolPipName
|
||||
}
|
||||
|
||||
step_4_info() {
|
||||
echo "Install $toolName features"
|
||||
echoinfo ${toolFeatures[*]}
|
||||
}
|
||||
step_4() {
|
||||
for i in "${!toolFeatures[@]}"; do
|
||||
toolFeatures[$i]="$toolPipName[${toolFeatures[$i]}]"
|
||||
done
|
||||
exe ${CALWEB_VENV_ROOT}/bin/pip install "${toolFeatures[@]}"
|
||||
}
|
||||
|
||||
step_5_info() { echo "Install systemd service"; }
|
||||
step_5() {
|
||||
addConf -s "$CALWEB_SERVICE" "$calweb_service_loc"
|
||||
[ $? -eq 0 ] && exe systemctl daemon-reload
|
||||
}
|
||||
calweb_service_name="calibreweb.service"
|
||||
calweb_service_loc="/etc/systemd/system/$calweb_service_name"
|
||||
|
||||
step_6_info() { echo "Enable and start systemd service"; }
|
||||
step_6() {
|
||||
exe systemctl enable $calweb_service_name --now
|
||||
}
|
||||
|
||||
step_15_info() { echo "Upgrade python pip"; }
|
||||
step_15_alias() { ALIAS="upgradepip"; }
|
||||
step_15()
|
||||
{
|
||||
exe ${CALWEB_VENV_ROOT}/bin/pip install --upgrade pip
|
||||
}
|
||||
|
||||
step_100_info() { echo "Setup notes"; }
|
||||
step_100_alias() { ALIAS="notes"; }
|
||||
step_100() {
|
||||
outColor green
|
||||
cat <<NOTES_END
|
||||
# Default admin login:
|
||||
|
||||
Username: admin
|
||||
Password: admin123
|
||||
|
||||
# nginx reverse proxy
|
||||
|
||||
nginx configuration for a local server listening on port 8083:
|
||||
|
||||
server {
|
||||
client_max_body_size 20M;
|
||||
location / {
|
||||
proxy_bind \$server_addr;
|
||||
proxy_pass http://127.0.0.1:8083;
|
||||
proxy_set_header Host \$http_host;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Scheme \$scheme;
|
||||
}
|
||||
}
|
||||
|
||||
## mapping Calibre-Web to a subfolder /calibre
|
||||
|
||||
Change/add the following lines in the configuration above:
|
||||
|
||||
location /calibre {
|
||||
proxy_set_header X-Script-Name /calibre; # IMPORTANT: path has NO trailing slash
|
||||
|
||||
NOTES_END
|
||||
}
|
||||
|
||||
VERSION_SEQREV=15
|
||||
. /usr/local/bin/sequencer.sh
|
Reference in New Issue
Block a user