Updates for packages
This commit is contained in:
24
roles/Yggdrasil/package/Makefile
Normal file
24
roles/Yggdrasil/package/Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
compile:
|
||||
@echo Nothing to do
|
||||
|
||||
install: clean
|
||||
mkdir -p ${pkgdir}/usr/local/bin/
|
||||
for i in yggdrasil-get yggdrasil-lock yggdrasil-set-music-data yggdrasil-sha256 yggdrasil-sort-shows yggdrasil-unlock; do install -m 0750 -o root -g http $$i ${pkgdir}/usr/local/bin/; done
|
||||
mkdir -p ${pkgdir}/usr/lib/systemd/system
|
||||
for i in *.timer *.service; do install -m 0755 -o root -g root $$i ${pkgdir}/usr/lib/systemd/system; done
|
||||
|
||||
test: compile
|
||||
@echo Nothing to do
|
||||
|
||||
clean:
|
||||
git clean -fX
|
||||
git clean -fd
|
||||
|
||||
diff:
|
||||
@echo Nothing to do.
|
||||
|
||||
reverse:
|
||||
@echo Nothing to do.
|
||||
|
||||
checkperm:
|
||||
@echo Nothing to do.
|
46
roles/Yggdrasil/package/PKGBUILD
Normal file
46
roles/Yggdrasil/package/PKGBUILD
Normal file
@@ -0,0 +1,46 @@
|
||||
depends=('bash>=4.4')
|
||||
makedepends=('make>=4.2')
|
||||
checkdepends=()
|
||||
optdepends=()
|
||||
pkgname="yggdrasil-scripts"
|
||||
pkgver="$(git describe --tag --abbrev=0)"."$(git rev-parse --short HEAD)"
|
||||
pkgrel=1
|
||||
pkgrel() {
|
||||
echo $(( `git log "$(git describe --tag --abbrev=0)"..HEAD | grep -c commit` + 1 ))
|
||||
}
|
||||
epoch="$(git log | grep -c commit)"
|
||||
pkgdesc="$(head -n 1 README.md)"
|
||||
arch=("x86_64")
|
||||
url="$(git config remote.origin.url | sed 's/.git$//')"
|
||||
license=('custom')
|
||||
groups=()
|
||||
provides=("${pkgname}")
|
||||
conflicts=()
|
||||
replaces=("${pkgname,,}", "aninix-${pkgname,,}")
|
||||
backup=()
|
||||
options=()
|
||||
install=
|
||||
changelog=
|
||||
source=()
|
||||
noextract=()
|
||||
md5sums=()
|
||||
validpgpkeys=()
|
||||
|
||||
prepare() {
|
||||
git pull
|
||||
}
|
||||
|
||||
build() {
|
||||
make -C ..
|
||||
}
|
||||
|
||||
check() {
|
||||
chmod -R u+r ../pkg
|
||||
make -C .. test
|
||||
}
|
||||
|
||||
package() {
|
||||
export pkgdir="${pkgdir}"
|
||||
make -C .. install
|
||||
install -D -m644 ../../../../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||
}
|
@@ -3,6 +3,6 @@ This is a collection of scripts we use for managing yggdrasil data.
|
||||
1. yggdrasil-get: API for pulling data into Yggdrasil.
|
||||
1. yggdrasil-lock: API for setting permissions safely.
|
||||
1. yggdrasil-set-music-data: API for updating a music file with the new detected metadata from the path. Assumes `/srv/yggdrasil/Music/$genre/$artist/$album`.
|
||||
1. yggdrasil-sha256: Get a SHA-256 hash of the current library. This is good for checking media changes over time in conjunction with [AniNIX/Aether](/AniNIX/Aether).
|
||||
1. yggdrasil-sha256: Get a SHA-256 hash of the current library. This is good for checking media changes over time in conjunction with [AniNIX/Aether](/AniNIX/Aether).
|
||||
1. yggdrasil-sort-shows: Look at `/srv/yggdrasil/new_acquisition` and try to find the right folder in `/srv/yggdrasil/Videos/Shows` to stash it in. Will try to put it under the show name and the season.
|
||||
1. yggdrasil-unlock: API for allowing writes to media.
|
||||
|
90
roles/Yggdrasil/package/yggdrasil-get
Executable file
90
roles/Yggdrasil/package/yggdrasil-get
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
export YGGDRASIL="/srv/yggdrasil"
|
||||
option="$1"
|
||||
path="$2"
|
||||
newname="$3"
|
||||
|
||||
#Offer help
|
||||
if [ "$option" == "" ] || [ "$option" == "-h" ] || [ "$option" == "--help" ] || [ "$path" == "" ] || [ $(echo $newname | grep -c '/') -ne 0 ]; then
|
||||
echo "AniNIX::Yggdrasil Bash API"
|
||||
echo 'Syntax: yggdrasil-get {dl|yt|mp3|sol|cp|mv} PATH [new file name in $PWD]'
|
||||
echo "Option:"
|
||||
echo "-- dl: Use wget"
|
||||
echo "-- yt: Use youtube-dl"
|
||||
echo "-- mp3: Use youtube-mp3"
|
||||
echo "-- sol: Use solarmovie-vodlocker-dl"
|
||||
echo "-- cp: Copy the file here."
|
||||
echo "-- mv: Move the file here."
|
||||
echo "-- mkdir: Make a folder"
|
||||
exit;
|
||||
fi
|
||||
|
||||
#Make sure we're in the Yggdrasil project.
|
||||
if [ $(expr match "$PWD" "$YGGDRASIL") -ne $(expr length "$YGGDRASIL") ]; then
|
||||
echo "Not in the Yggdrasil directory.";
|
||||
exit;
|
||||
fi
|
||||
|
||||
#unlock this directory
|
||||
chmod ug+w "$PWD"
|
||||
|
||||
#Appropriately source the file
|
||||
if [ $? -ne 0 ]; then
|
||||
echo Couldn\'t unlock $PWD
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$option" == "dl" ]; then
|
||||
if [ "$newname" != "" ]; then
|
||||
wget -O "$newname" "$path";
|
||||
else
|
||||
wget "$path";
|
||||
fi
|
||||
fi
|
||||
if [ "$option" == "yt" ]; then
|
||||
if [ `echo "$path" | grep -c '/watch?v='` -eq 1 ]; then
|
||||
path="$(echo "$path" | cut -f 1 -d '&')"
|
||||
fi
|
||||
if [ "$newname" != "" ]; then
|
||||
youtube-dl -o "$newname" "$path";
|
||||
else
|
||||
youtube-dl "$path";
|
||||
fi
|
||||
fi
|
||||
if [ "$option" == "mp3" ]; then
|
||||
if [ "$newname" != "" ]; then
|
||||
echo "Renaming not available."
|
||||
fi
|
||||
if [ `echo "$path" | grep -c '/watch?v='` -eq 1 ]; then
|
||||
path="$(echo "$path" | cut -f 1 -d '&')"
|
||||
fi
|
||||
youtube-mp3 "$path";
|
||||
yggdrasil-set-music-data *.mp3
|
||||
fi
|
||||
if [ "$option" == "sol" ]; then
|
||||
if [ "$newname" != "" ]; then
|
||||
solarmovie-vodlocker-dl "$path" "$newname"
|
||||
else
|
||||
echo "Need a name."
|
||||
fi
|
||||
fi
|
||||
if [ "$option" == "cp" ]; then
|
||||
if [ "$newname" != "" ]; then
|
||||
cp "$path" ./"$newname"
|
||||
else
|
||||
cp "$path" .
|
||||
fi
|
||||
fi
|
||||
if [ "$option" == "mv" ]; then
|
||||
if [ "$newname" != "" ]; then
|
||||
mv "$path" ./"$newname"
|
||||
else
|
||||
mv "$path" .
|
||||
fi
|
||||
fi
|
||||
if [[ "$option" == "mkdir" && "$path" != "" ]]; then
|
||||
mkdir -p "$path"
|
||||
fi
|
||||
#Lock
|
||||
chmod -R ug-w "$PWD"
|
5
roles/Yggdrasil/package/yggdrasil-lock
Executable file
5
roles/Yggdrasil/package/yggdrasil-lock
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
chown -P -R DarkFeather:http /srv/yggdrasil
|
||||
find -P /srv/yggdrasil/ -type f -exec chmod 0440 {} \;
|
||||
find -P /srv/yggdrasil/ -type d -exec chmod 0550 {} \;
|
||||
chmod -R u+w /srv/yggdrasil/new_acquisition
|
48
roles/Yggdrasil/package/yggdrasil-set-music-data
Executable file
48
roles/Yggdrasil/package/yggdrasil-set-music-data
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
parser="$(echo $PWD | rev)"
|
||||
IFS="
|
||||
"
|
||||
|
||||
partist="$(echo $parser | cut -f 2 -d '/' | rev)"
|
||||
palbum="$(echo $parser | cut -f 1 -d '/' | rev)"
|
||||
pgenre="$(echo $parser | cut -f 3 -d '/' | rev)"
|
||||
|
||||
if [ "$partist" == "" ] || [ "$palbum" == "" ] || [ "$pgenre" == "" ]; then
|
||||
echo "This script expects a format of "'$MUSICBASEPATH'"/Genre/Artist/Album/Song.ext"
|
||||
exit;
|
||||
fi
|
||||
echo Expected metadata:
|
||||
echo Artist: $partist
|
||||
echo Album: $palbum
|
||||
echo Genre: $pgenre
|
||||
echo
|
||||
|
||||
for i in $@; do
|
||||
if [ ! -f "$i" ]; then
|
||||
echo File doesn\'t exist. $i
|
||||
continue;
|
||||
fi
|
||||
ffartist="$(ffprobe -hide_banner -i $i 2>&1 | grep artist | grep -v 'album_artist' | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sed -e 's/*[[:space:]]$//')"
|
||||
ffalbum="$(ffprobe -hide_banner -i $i 2>&1 | grep album | grep -v 'album_artist' | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sed -e 's/*[[:space:]]$//')"
|
||||
ffgenre="$(ffprobe -hide_banner -i $i 2>&1 | grep genre | head -n 1 | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sed -e 's/*[[:space:]]$//')"
|
||||
echo For \[$i\]...
|
||||
unset tags
|
||||
echo Found artist \[$ffartist\]
|
||||
if [ "$partist" != "$ffartist" ]; then
|
||||
export tags=$tags" -metadata artist=\"$partist\""
|
||||
fi
|
||||
echo Found album \[$ffalbum\]
|
||||
if [ "$ffalbum" != "$palbum" ]; then
|
||||
export tags=$tags" -metadata album=\"$palbum\""
|
||||
fi
|
||||
echo Found genre \[$ffgenre\]
|
||||
if [ "$ffgenre" != "$pgenre" ]; then
|
||||
export tags=$tags" -metadata genre=\"$pgenre\""
|
||||
fi
|
||||
if [ "$tags" != "" ]; then
|
||||
bash -c "ffmpeg -hide_banner -i \"$i\"$tags \"$i.ffmpeg.mp3\""
|
||||
mv "$i.ffmpeg.mp3" "$i"
|
||||
fi
|
||||
echo
|
||||
done
|
26
roles/Yggdrasil/package/yggdrasil-sha256
Executable file
26
roles/Yggdrasil/package/yggdrasil-sha256
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
basedir="/srv/yggdrasil"
|
||||
shafile="$basedir""/library.sha256"
|
||||
|
||||
option="$1"
|
||||
|
||||
if [ "$option" == "-h" ] || [ "$option" == "--help" ]; then
|
||||
echo Usage: $0 '[verify]'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$option" != "verify" ]]; then
|
||||
chmod u+w "$basedir"
|
||||
touch "$shafile"
|
||||
chmod u+w "$shafile"
|
||||
find "$basedir" -type f -exec sha256sum {} \; > "$shafile"
|
||||
chmod u-w "$basedir" "$shafile"
|
||||
exit 0;
|
||||
else
|
||||
echo "These files have problems:"
|
||||
sha256sum -c "$shafile";
|
||||
exit $?;
|
||||
fi
|
74
roles/Yggdrasil/package/yggdrasil-sort-shows
Executable file
74
roles/Yggdrasil/package/yggdrasil-sort-shows
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
baseDir="/srv/yggdrasil/Videos/Shows"
|
||||
|
||||
# Helptext
|
||||
function usage() {
|
||||
echo Sort files from /srv/yggdrasil/new_acquisition into appropriate show directories.
|
||||
echo
|
||||
echo Usage: $0 '[ -h ] [ -f fileToUse ] [ -c ] [ -n ] [ -q ] [ -v ]'
|
||||
echo ' -c: Create sample sort file'
|
||||
echo ' -f: Use this sort file'
|
||||
echo ' -h: print this helptext.'
|
||||
echo ' -n: Do not lock the libary -- this is useful for sorting other things after execution.'
|
||||
echo ' -q: Mute output'
|
||||
echo ' -v: Increase verbosity'
|
||||
}
|
||||
|
||||
# Handle a file
|
||||
# param file: the file to parse
|
||||
function HandleFile() {
|
||||
file="$1"
|
||||
# Sort out file metadata
|
||||
dirtyshowname="$(echo "$file" | sed 's/.[Ss][0-9].[Ee][0-9].*$//')"
|
||||
showname="$(ls -1 "$baseDir" | grep -iE "$dirtyshowname")"
|
||||
epinfo="$(echo "$file" | sed "s/^${dirtyshowname}.//" | head -c 6)"
|
||||
season="$(echo "$epinfo" | head -c 3 | tail -c 2)"
|
||||
episode="$(echo -n "$epinfo" | tail -c 2)"
|
||||
target="$baseDir"/"$showname"/Season\ "$season"
|
||||
# Ensure metadata sorting didn't return nulls
|
||||
for i in dirtyshowname showname epinfo season episode target; do
|
||||
if [ -z "${!i}" ]; then
|
||||
echo ERROR: Could not handle "$file" because we could not find $i
|
||||
return
|
||||
fi
|
||||
done
|
||||
# Make sure target exists
|
||||
# Move file to target
|
||||
if [ ! -d "$(dirname "$target")" ]; then
|
||||
echo WARN -- could not find the right show to sort "$file"
|
||||
fi
|
||||
# Make sure the show folder exists
|
||||
mkdir -p "$target"
|
||||
mv "$file" "$target"
|
||||
}
|
||||
|
||||
|
||||
# Parse arguments.
|
||||
while getopts 'b:cf:hnqv' OPTION; do
|
||||
case "$OPTION" in
|
||||
b) baseDir="${OPTARG}" ;;
|
||||
h) usage; exit 0 ;;
|
||||
l) exec $0 $(echo $@ | sed "s/-s\s+${OPTARG}(.|$)//") | tee -a "${OPTARG}" ;;
|
||||
n) nolock="1" ;;
|
||||
q) exec $0 $(echo $@ | sed 's/-q//') &>/dev/null ;;
|
||||
v) set -x ;;
|
||||
*) usage; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd /srv/yggdrasil/new_acquisition
|
||||
|
||||
echo INFO Unlocking filestore
|
||||
if [ `whoami` != "root" ]; then yggdrasil-unlock; fi
|
||||
|
||||
echo INFO Sorting....
|
||||
# Find all files matching *S??E??* syntax
|
||||
ls -1d *[S,s]??[E,e]??* 2>/dev/null | while read file; do
|
||||
HandleFile "${file}"
|
||||
done
|
||||
|
||||
if [ -z "$nolock" ] && [ `whoami` != "root" ]; then
|
||||
echo INFO Locking filestore
|
||||
yggdrasil-lock &>/dev/null
|
||||
fi
|
12
roles/Yggdrasil/package/yggdrasil-sort-shows.service
Normal file
12
roles/Yggdrasil/package/yggdrasil-sort-shows.service
Normal file
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=AniNIX/Yggdrasil | Sort shows
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/local/bin/yggdrasil-unlock
|
||||
ExecStart=/usr/local/bin/yggdrasil-sort-shows
|
||||
ExecStartPost=/usr/local/bin/yggdrasil-lock
|
||||
KillMode=process
|
||||
Type=oneshot
|
||||
RemainAfterExit=no
|
||||
User=root
|
||||
Group=root
|
10
roles/Yggdrasil/package/yggdrasil-sort-shows.timer
Normal file
10
roles/Yggdrasil/package/yggdrasil-sort-shows.timer
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=AniNIX/Yggdrasil | Sort shows timer
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*:0/15
|
||||
AccuracySec=12h
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
2
roles/Yggdrasil/package/yggdrasil-unlock
Executable file
2
roles/Yggdrasil/package/yggdrasil-unlock
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
find -P /srv/yggdrasil -type d -exec chmod u+w {} \;
|
Reference in New Issue
Block a user