Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added daemon installation for Fedora
user instance of systemd can handle the ytdl_server.py as daemon for us. also use virtualenv for pip installed user package to not ever clash with site-packages where all/most of things is rpm managed
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! /bin/bash | ||
set -ex | ||
|
||
YMPV_DIR="$(readlink -f "$(dirname "$0")")" | ||
VENV="${XDG_DATA_HOME:-$YMPV_DIR}/.youtube-mpv-venv" | ||
CFGDIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user" | ||
|
||
|
||
# install dependencies | ||
|
||
if ! (which pip && which virtualenv) > /dev/null; then | ||
sudo dnf install -y python-pip python-virtualenv | ||
fi | ||
[[ -e "$VENV/bin/activate" ]] || virtualenv "$VENV" | ||
source "$VENV/bin/activate" | ||
python -m youtube_dl --help &> /dev/null || pip install youtube_dl | ||
|
||
|
||
# register as systemd service | ||
|
||
mkdir -p "$CFGDIR" | ||
cat > "$CFGDIR/youtube-mpv.service" <<EOF | ||
[Unit] | ||
Description=Python server which can play youtube links | ||
[Service] | ||
Type=simple | ||
ExecStart=${VENV}/bin/python "${YMPV_DIR}/ytdl_server.py" | ||
[Install] | ||
WantedBy=default.target | ||
EOF | ||
|
||
# start the service | ||
|
||
systemctl --user daemon-reload | ||
systemctl --user restart youtube-mpv | ||
systemctl --user enable youtube-mpv |