feat: add pinchflat lxc script
This commit is contained in:
141
ct/pinchflat.sh
Normal file
141
ct/pinchflat.sh
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://raw.githubusercontent.com/nnsense/ProxmoxVED/main}"
|
||||||
|
source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func")
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2026 community-scripts ORG
|
||||||
|
# Author: nnsense
|
||||||
|
# License: MIT | https://github.com/--full/ProxmoxVED/raw/main/LICENSE
|
||||||
|
# Source: https://github.com/kieraneglin/pinchflat
|
||||||
|
|
||||||
|
APP="Pinchflat"
|
||||||
|
var_tags="${var_tags:-media;youtube;downloader}"
|
||||||
|
var_cpu="${var_cpu:-2}"
|
||||||
|
var_ram="${var_ram:-2048}"
|
||||||
|
var_disk="${var_disk:-8}"
|
||||||
|
var_os="${var_os:-debian}"
|
||||||
|
var_version="${var_version:-13}"
|
||||||
|
var_unprivileged="${var_unprivileged:-1}"
|
||||||
|
|
||||||
|
header_info "$APP"
|
||||||
|
variables
|
||||||
|
color
|
||||||
|
catch_errors
|
||||||
|
|
||||||
|
function default_settings() {
|
||||||
|
CT_TYPE="1"
|
||||||
|
PW=""
|
||||||
|
CT_ID=$NEXTID
|
||||||
|
HN=$NSAPP
|
||||||
|
DISK_SIZE="$var_disk"
|
||||||
|
CORE_COUNT="$var_cpu"
|
||||||
|
RAM_SIZE="$var_ram"
|
||||||
|
BRG="vmbr0"
|
||||||
|
NET="dhcp"
|
||||||
|
GATE=""
|
||||||
|
APT_CACHER=""
|
||||||
|
APT_CACHER_IP=""
|
||||||
|
DISABLEIP6="no"
|
||||||
|
MTU=""
|
||||||
|
SD=""
|
||||||
|
NS=""
|
||||||
|
MAC=""
|
||||||
|
VLAN=""
|
||||||
|
SSH="no"
|
||||||
|
VERB="no"
|
||||||
|
DOWNLOADS_PATH="/opt/pinchflat/downloads"
|
||||||
|
echo_default
|
||||||
|
}
|
||||||
|
|
||||||
|
function advanced_settings() {
|
||||||
|
whiptail --backtitle "Proxmox VE Helper Scripts" --title "$APP LXC" --yesno "Use advanced settings?" 10 58 || return
|
||||||
|
|
||||||
|
CT_TYPE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Container Type" --radiolist "Choose container type" 10 58 2 \
|
||||||
|
"1" "Unprivileged" ON \
|
||||||
|
"0" "Privileged" OFF 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
HN=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Hostname" 8 58 "$NSAPP" 3>&1 1>&2 2>&3)
|
||||||
|
CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "CPU cores" 8 58 "$var_cpu" 3>&1 1>&2 2>&3)
|
||||||
|
RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "RAM in MiB" 8 58 "$var_ram" 3>&1 1>&2 2>&3)
|
||||||
|
DISK_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Disk size in GiB" 8 58 "$var_disk" 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
DOWNLOADS_PATH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Pinchflat Downloads" --inputbox \
|
||||||
|
"Downloads path inside the LXC.
|
||||||
|
|
||||||
|
Default: /opt/pinchflat/downloads
|
||||||
|
Example external mount path: /mnt/pinchflat
|
||||||
|
|
||||||
|
If the path does not exist during installation, it will be created locally.
|
||||||
|
You can later stop the LXC, mount external storage at the same path, and start it again." \
|
||||||
|
18 78 "/opt/pinchflat/downloads" 3>&1 1>&2 2>&3)
|
||||||
|
DOWNLOADS_PATH="${DOWNLOADS_PATH:-/opt/pinchflat/downloads}"
|
||||||
|
|
||||||
|
BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Bridge" 8 58 "vmbr0" 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Network" --yesno "Use DHCP?" 8 58; then
|
||||||
|
NET="dhcp"
|
||||||
|
GATE=""
|
||||||
|
else
|
||||||
|
NET=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Static IP/CIDR" 8 58 "192.168.0.100/24" 3>&1 1>&2 2>&3)
|
||||||
|
GATE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Gateway" 8 58 "192.168.0.1" 3>&1 1>&2 2>&3)
|
||||||
|
fi
|
||||||
|
|
||||||
|
APT_CACHER=""
|
||||||
|
APT_CACHER_IP=""
|
||||||
|
DISABLEIP6="no"
|
||||||
|
MTU=""
|
||||||
|
SD=""
|
||||||
|
NS=""
|
||||||
|
MAC=""
|
||||||
|
VLAN=""
|
||||||
|
SSH="no"
|
||||||
|
VERB="no"
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_script() {
|
||||||
|
header_info
|
||||||
|
check_container_storage
|
||||||
|
check_container_resources
|
||||||
|
|
||||||
|
if [[ ! -d /opt/pinchflat/app ]]; then
|
||||||
|
msg_error "No ${APP} installation found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if check_for_gh_release "pinchflat" "kieraneglin/pinchflat"; then
|
||||||
|
msg_info "Stopping Service"
|
||||||
|
systemctl stop pinchflat
|
||||||
|
msg_ok "Stopped Service"
|
||||||
|
|
||||||
|
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "pinchflat" "kieraneglin/pinchflat" "tarball" "latest" "/opt/pinchflat-src"
|
||||||
|
|
||||||
|
msg_info "Building Pinchflat"
|
||||||
|
cd /opt/pinchflat-src || exit 1
|
||||||
|
export MIX_ENV=prod
|
||||||
|
export ERL_FLAGS="+JPperf true"
|
||||||
|
$STD mix deps.get --only prod
|
||||||
|
$STD mix deps.compile
|
||||||
|
$STD yarn --cwd assets install
|
||||||
|
$STD mix assets.deploy
|
||||||
|
$STD mix compile
|
||||||
|
$STD mix release --overwrite
|
||||||
|
rm -rf /opt/pinchflat/app
|
||||||
|
cp -r _build/prod/rel/pinchflat /opt/pinchflat/app
|
||||||
|
msg_ok "Built Pinchflat"
|
||||||
|
|
||||||
|
msg_info "Starting Service"
|
||||||
|
systemctl start pinchflat
|
||||||
|
msg_ok "Started Service"
|
||||||
|
msg_ok "Updated successfully!"
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
export DOWNLOADS_PATH
|
||||||
|
|
||||||
|
start
|
||||||
|
build_container
|
||||||
|
description
|
||||||
|
msg_ok "Completed Successfully!\n"
|
||||||
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8945${CL}"
|
||||||
150
install/pinchflat-install.sh
Normal file
150
install/pinchflat-install.sh
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2026 community-scripts ORG
|
||||||
|
# Author: nnsense
|
||||||
|
# License: MIT | https://github.com/nnsense/ProxmoxVED/raw/main/LICENSE
|
||||||
|
# Source: https://github.com/kieraneglin/pinchflat
|
||||||
|
|
||||||
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||||
|
|
||||||
|
color
|
||||||
|
verb_ip6
|
||||||
|
catch_errors
|
||||||
|
setting_up_container
|
||||||
|
network_check
|
||||||
|
update_os
|
||||||
|
|
||||||
|
msg_info "Installing Dependencies"
|
||||||
|
$STD apt install -y \
|
||||||
|
build-essential \
|
||||||
|
elixir \
|
||||||
|
erlang-dev \
|
||||||
|
git \
|
||||||
|
libsqlite3-dev \
|
||||||
|
locales \
|
||||||
|
openssh-client \
|
||||||
|
openssl \
|
||||||
|
pipx \
|
||||||
|
pkg-config \
|
||||||
|
procps \
|
||||||
|
python3-mutagen \
|
||||||
|
unzip \
|
||||||
|
zip
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
NODE_VERSION="20" NODE_MODULE="yarn" setup_nodejs
|
||||||
|
FFMPEG_TYPE="binary" setup_ffmpeg
|
||||||
|
|
||||||
|
case "$(dpkg --print-architecture)" in
|
||||||
|
arm64)
|
||||||
|
DENO_ASSET="deno-aarch64-unknown-linux-gnu.zip"
|
||||||
|
YT_DLP_ASSET="yt-dlp_linux_aarch64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
DENO_ASSET="deno-x86_64-unknown-linux-gnu.zip"
|
||||||
|
YT_DLP_ASSET="yt-dlp_linux"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fetch_and_deploy_gh_release "deno" "denoland/deno" "prebuild" "latest" "/usr/local/bin" "$DENO_ASSET"
|
||||||
|
fetch_and_deploy_gh_release "yt-dlp" "yt-dlp/yt-dlp" "singlefile" "latest" "/usr/local/bin" "$YT_DLP_ASSET"
|
||||||
|
|
||||||
|
msg_info "Installing Apprise"
|
||||||
|
export PIPX_HOME=/opt/pipx
|
||||||
|
export PIPX_BIN_DIR=/usr/local/bin
|
||||||
|
$STD pipx install apprise
|
||||||
|
msg_ok "Installed Apprise"
|
||||||
|
|
||||||
|
msg_info "Setting Locale"
|
||||||
|
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen
|
||||||
|
$STD locale-gen
|
||||||
|
msg_ok "Set Locale"
|
||||||
|
|
||||||
|
fetch_and_deploy_gh_release "pinchflat" "kieraneglin/pinchflat" "tarball" "latest" "/opt/pinchflat-src"
|
||||||
|
|
||||||
|
msg_info "Configuring Pinchflat"
|
||||||
|
CONFIG_PATH="/opt/pinchflat/config"
|
||||||
|
LOCAL_DOWNLOADS_PATH="/opt/pinchflat/downloads"
|
||||||
|
DOWNLOADS_PATH="${DOWNLOADS_PATH:-$LOCAL_DOWNLOADS_PATH}"
|
||||||
|
SECRET_KEY_BASE=$(openssl rand -base64 48)
|
||||||
|
|
||||||
|
mkdir -p \
|
||||||
|
/etc/elixir_tzdata_data \
|
||||||
|
/etc/yt-dlp/plugins \
|
||||||
|
/opt/pinchflat/app \
|
||||||
|
"$CONFIG_PATH/db" \
|
||||||
|
"$CONFIG_PATH/extras" \
|
||||||
|
"$CONFIG_PATH/logs" \
|
||||||
|
"$CONFIG_PATH/metadata" \
|
||||||
|
"$DOWNLOADS_PATH"
|
||||||
|
ln -sfn "$CONFIG_PATH" /config
|
||||||
|
ln -sfn "$DOWNLOADS_PATH" /downloads
|
||||||
|
chmod ugo+rw /etc/elixir_tzdata_data /etc/yt-dlp /etc/yt-dlp/plugins
|
||||||
|
|
||||||
|
cat <<EOF >/opt/pinchflat/.env
|
||||||
|
LANG=en_US.UTF-8
|
||||||
|
LANGUAGE=en_US:en
|
||||||
|
LC_ALL=en_US.UTF-8
|
||||||
|
MIX_ENV=prod
|
||||||
|
PHX_SERVER=true
|
||||||
|
PORT=8945
|
||||||
|
RUN_CONTEXT=selfhosted
|
||||||
|
CONFIG_PATH=${CONFIG_PATH}
|
||||||
|
MEDIA_PATH=${DOWNLOADS_PATH}
|
||||||
|
TZ_DATA_PATH=/etc/elixir_tzdata_data
|
||||||
|
SECRET_KEY_BASE=${SECRET_KEY_BASE}
|
||||||
|
EOF
|
||||||
|
msg_ok "Configured Pinchflat"
|
||||||
|
|
||||||
|
msg_info "Building Pinchflat"
|
||||||
|
cd /opt/pinchflat-src
|
||||||
|
export MIX_ENV=prod
|
||||||
|
export ERL_FLAGS="+JPperf true"
|
||||||
|
$STD mix local.hex --force
|
||||||
|
$STD mix local.rebar --force
|
||||||
|
$STD mix deps.get --only prod
|
||||||
|
$STD mix deps.compile
|
||||||
|
$STD yarn --cwd assets install
|
||||||
|
$STD mix assets.deploy
|
||||||
|
$STD mix compile
|
||||||
|
$STD mix release --overwrite
|
||||||
|
rm -rf /opt/pinchflat/app
|
||||||
|
cp -r _build/prod/rel/pinchflat /opt/pinchflat/app
|
||||||
|
msg_ok "Built Pinchflat"
|
||||||
|
|
||||||
|
msg_info "Creating Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/pinchflat.service
|
||||||
|
[Unit]
|
||||||
|
Description=Pinchflat
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
EnvironmentFile=/opt/pinchflat/.env
|
||||||
|
WorkingDirectory=/opt/pinchflat/app
|
||||||
|
UMask=0022
|
||||||
|
ExecStartPre=/opt/pinchflat/app/bin/check_file_permissions
|
||||||
|
ExecStartPre=/opt/pinchflat/app/bin/migrate
|
||||||
|
ExecStart=/opt/pinchflat/app/bin/pinchflat start
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now pinchflat
|
||||||
|
msg_ok "Created Service"
|
||||||
|
|
||||||
|
cat <<EOF >/opt/pinchflat/README
|
||||||
|
Pinchflat is installed as a systemd service.
|
||||||
|
|
||||||
|
Web UI: http://<LXC-IP>:8945
|
||||||
|
Config path: ${CONFIG_PATH}
|
||||||
|
Downloads path: ${DOWNLOADS_PATH}
|
||||||
|
|
||||||
|
If an external downloads path was selected, mount it inside the LXC at the same path.
|
||||||
|
If the path did not exist during installation, it was created locally and can later be replaced by the mount.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
cleanup_lxc
|
||||||
Reference in New Issue
Block a user