Updates for packages
This commit is contained in:
parent
f139ea55b4
commit
59b3181d61
@ -1,4 +1,4 @@
|
||||
binlist = ldap-adduser ldap-userreport ldap-resetpass
|
||||
binlist = ldap-adduser ldap-userreport ldap-resetpass ldap-recreateuser
|
||||
filelist = sample-user.ldif
|
||||
|
||||
compile:
|
||||
|
22
roles/Password/package/ldap-recreateuser
Executable file
22
roles/Password/package/ldap-recreateuser
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
uid="$1"
|
||||
userfile="/etc/openldap/users.d/$uid.ldif"
|
||||
|
||||
if [ -z "$uid" ]; then
|
||||
echo "Need a user ID (uid)!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f "$userfile" ]; then
|
||||
ldapsearch -x "uid=${uid}" > "$userfile"
|
||||
echo "$userfile" had to be created -- please validate before re-running this script.
|
||||
exit 2
|
||||
fi
|
||||
|
||||
read -sp 'cn=root,dc=aninix,dc=net Password: ' rootdnpw
|
||||
ldapdelete -D 'cn=root,dc=aninix,dc=net' -w "$rootdnpw" -H ldap://127.0.0.1 "uid=$uid,ou=People,dc=aninix,dc=net" && \
|
||||
ldapadd -D 'cn=root,dc=aninix,dc=net' -w "$rootdnpw" -H ldap://127.0.0.1 -f "$userfile"
|
||||
|
||||
exit $?
|
@ -7,8 +7,25 @@ if [ -z "$uid" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ldappasswd -D 'cn=root,dc=aninix,dc=net' -W -H ldap://127.0.0.1 "uid=$uid,ou=People,dc=aninix,dc=net"
|
||||
read -sp 'cn=root,dc=aninix,dc=net Password: ' rootdnpw
|
||||
|
||||
#ldapmodify -D 'cn=root,dc=aninix,dc=net' -W -H ldap://127.0.0.1 -f <(printf "dn: uid=$uid,ou=People,dc=aninix,dc=net\nchangetype: modify\nadd: pwdReset\npwdReset: TRUE\n\n")
|
||||
ldappasswd -D 'cn=root,dc=aninix,dc=net' -w "$rootdnpw" -H ldap://127.0.0.1 "uid=$uid,ou=People,dc=aninix,dc=net" && \
|
||||
ldapmodify -D 'cn=root,dc=aninix,dc=net' -w "$rootdnpw" -H ldap://127.0.0.1 -f <(cat <<EOM
|
||||
dn: uid=$uid,ou=People,dc=aninix,dc=net
|
||||
changetype: modify
|
||||
add: pwdReset
|
||||
pwdReset: TRUE
|
||||
|
||||
|
||||
EOM
|
||||
)
|
||||
|
||||
echo 'As cn=root,cn=config...' && ldapmodify -D 'cn=root,cn=config' -W -H ldap://127.0.0.1 -f <(cat <<EOM
|
||||
dn: uid=$uid,ou=People,dc=aninix,dc=net
|
||||
changetype: modify
|
||||
delete: pwdChangedTime
|
||||
|
||||
|
||||
EOM
|
||||
)
|
||||
exit $?
|
||||
|
@ -1,54 +1,95 @@
|
||||
#!/bin/bash
|
||||
|
||||
hostname=`hostname`
|
||||
errortext="ERROR:NEVER"
|
||||
arg="$1"
|
||||
|
||||
function shortshow() {
|
||||
echo ${user}": "$email
|
||||
function getLDAPAttr() {
|
||||
### Get an LDAP attribute
|
||||
# param: filter
|
||||
# param attribute
|
||||
filter="${1}"
|
||||
attribute="${2}"
|
||||
ldapsearch -x "${filter}" "${attribute}" | grep -E "^${attribute}: " | sed "s/${attribute}: //"
|
||||
}
|
||||
|
||||
basedn=`ldapsearch -x '(cn=root)' dn | grep -E ^dn:\ | sed 's/dn: cn=root,//'`
|
||||
# Clear cleanup files
|
||||
ldif="/root/cleanup.ldif"
|
||||
>"${ldif}"
|
||||
bash="/root/cleanup.bash"
|
||||
echo "#!/bin/bash" > "${bash}"
|
||||
|
||||
for user in `ldapsearch -x -b "ou=People,$basedn" '(uid=*)' uid | grep -E ^uid:\ | sed 's/^uid: //'`; do
|
||||
# Attributes
|
||||
basedn=`getLDAPAttr '(cn=root)' dn | sed 's/cn=root,//'`
|
||||
pwdMaxAge=`getLDAPAttr '(&(cn=default)(objectClass=pwdPolicy))' pwdMaxAge`
|
||||
warning=`getLDAPAttr '(&(cn=default)(objectClass=pwdPolicy))' pwdExpireWarning`
|
||||
pwdWarnAge=$(( $pwdMaxAge - $warning ))
|
||||
unset EXPIRED EXPIRING OK PENDING
|
||||
|
||||
### Check all users
|
||||
for user in `ldapsearch -x -b "ou=People,$basedn" uid | grep -E ^uid:\ | sed 's/^uid: //'`; do
|
||||
|
||||
# Pull changed stats
|
||||
lastChanged=`/usr/sbin/ldapsearch -x "(uid=$user)" + | grep pwdChangedTime | cut -f 2 -d ' '`
|
||||
created=`/usr/sbin/ldapsearch -x "(uid=$user)" + | grep createTimestamp | cut -f 2 -d ' '`
|
||||
email=`/usr/sbin/ldapsearch -x "(uid=$user)" | grep mail | cut -f 2 -d ' '`
|
||||
# created=`/usr/sbin/ldapsearch -x "(uid=$user)" + | grep createTimestamp | cut -f 2 -d ' '`
|
||||
# email=`/usr/sbin/ldapsearch -x "(uid=$user)" | grep mail | cut -f 2 -d ' '`
|
||||
|
||||
# If user has PENDING changed, report
|
||||
if [ -z "$lastChanged" ]; then
|
||||
lastChanged="$errortext";
|
||||
if [ -z "${PENDING}" ]; then
|
||||
PENDING="${user}"
|
||||
else
|
||||
PENDING="${PENDING},${user}"
|
||||
fi
|
||||
|
||||
else
|
||||
delta="$(( `date +%s` - `date -d $(echo $lastChanged | head -c 8) +%s`))"
|
||||
fi
|
||||
lastlog=`lastlog -u $user | tail -n 1`
|
||||
if [ `echo $lastlog | grep -c 'Never logged in'` -gt 0 ]; then
|
||||
lastlog=$errortext
|
||||
else
|
||||
lastlog=`echo $lastlog | awk '{$1="";$2="";$3="";print $0 }'`
|
||||
fi
|
||||
printf "User $user (email: $email, created: $created) last changed their password on $lastChanged. They last logged in to SSH on $hostname on $lastlog\n" | (
|
||||
case "$arg" in
|
||||
"--inactive")
|
||||
if grep -E $errortext'$' &> /dev/null; then shortshow; fi
|
||||
;;
|
||||
"--needschange")
|
||||
if [ "$lastChanged" == "$errortext" ]; then
|
||||
shortshow
|
||||
|
||||
# Report if user is expired
|
||||
if [ $delta -gt $pwdMaxAge ]; then
|
||||
if [ -z "${EXPIRED}" ]; then
|
||||
EXPIRED="${user}"
|
||||
else
|
||||
if [ $delta -gt 28512000 ] && [ $delta -lt 31536000 ]; then shortshow; fi
|
||||
EXPIRED="${EXPIRED},${user}"
|
||||
fi
|
||||
;;
|
||||
"--expired")
|
||||
if [ "$lastChanged" != "$errortext" ] && [ "$delta" -ge 31536000 ]; then
|
||||
shortshow;
|
||||
printf "dn: uid=${user},ou=People,${basedn}\nchangetype: delete\n\n" >> "${ldif}"
|
||||
printf "rm -Rf `getent passwd "${user}" | cut -f 6 -d ':'`\n" >> "${bash}"
|
||||
|
||||
# Report if the user is expiring and needs to update their password.
|
||||
elif [ $delta -gt $pwdWarnAge ] && [ $delta -le $pwdMaxAge ]; then
|
||||
if [ -z "${EXPIRING}" ]; then
|
||||
EXPIRING="${user}"
|
||||
else
|
||||
EXPIRING="${EXPIRING},${user}"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
cat
|
||||
;;
|
||||
esac
|
||||
)
|
||||
|
||||
# Record the user account is OK.
|
||||
else
|
||||
if [ -z "${OK}" ]; then
|
||||
OK="${user}"
|
||||
else
|
||||
OK="${OK},${user}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
### Results
|
||||
# Should always have OK users in the tree.
|
||||
echo "OK: ${OK}"
|
||||
|
||||
# Report when there are users that have not changed their password.
|
||||
# This may be normal, such as for new user accounts, and may not drive action.
|
||||
if [ -n "$PENDING" ]; then
|
||||
echo "PENDING: ${PENDING}"
|
||||
fi
|
||||
|
||||
# Report when users are expiring -- give them several notices to fix it.
|
||||
if [ -n "${EXPIRING}" ]; then
|
||||
echo "EXPIRING: ${EXPIRING}"
|
||||
ravensend -c "#tech" -m "The following users are expiring: ${EXPIRING}"
|
||||
fi
|
||||
|
||||
# Report users that have expired. These users should be contacted or removed.
|
||||
if [ -n "${EXPIRED}" ]; then
|
||||
echo "EXPIRED: ${EXPIRED}"
|
||||
echo "Expired users can be cleaned up with ${ldif} and ${bash}"
|
||||
ravensend -c "#sharingan" -m 'Users have expired and need attention.'
|
||||
fi
|
||||
|
@ -7,7 +7,7 @@ The gallows are sometimes described in Old Norse poetry as the "horse of the han
|
||||
|
||||
Fjölsvinnsmál, a poem in the Poetic Edda, refers to the World Tree as Mimameid (Old Norse: Mímameiðr, "Mímir's tree" ). The tree is also probably identical to Laerad (Old Norse: Læraðr) a tree whose leaves and branches reach down to the roof of Valhalla and provide food for the goat Heidrun (Old Norse: Heiðrún) and the stag Eikthyrnir (Old Norse: Eikþyrnir).
|
||||
|
||||
## The Nine Worlds
|
||||
## The Nine Worlds
|
||||
The Yggdrasil tree is home to the Nine Worlds in Norse Cosmology. The worlds are:
|
||||
In the north: Niflheim
|
||||
In the east: Jotunheim
|
||||
@ -17,12 +17,12 @@ In the center: Midgard
|
||||
Above: Alfheim and Asgard
|
||||
Below: Svartalfheim and Helheim
|
||||
|
||||
## Residents
|
||||
## Residents
|
||||
The World Tree is inhabited by several animals, the Nίðhӧggr, pet dragon of the goddess Hel which chews the roots of the tree which bind it, Veðrfӧlnir the rooster, who will crow when Ragnarok occurs, Ratatӧsk the squirrel, who carries messages of hate between the eagle and the Nίðhӧggr. This eagle, who is not named, is said to have knowledge of many things, and on its head sits Veðrfӧlnir. The significance of Veðrfӧlnir is unclear but John Lindow suggests that it may represent a higher faculty of wisdom, possibly sent out to acquire knowledge in a similar manner as Odin's ravens Hugin and Munin.
|
||||
|
||||
The original Norn was undoubtedly Urd, a word which can be translated to mean "Fate". The Well of Urd, which was situated at the base of the great cosmic tree Yggdrasil, is named after this Norn. The two additional Norns that are known by name are Verdandi ("Present" [or "Necessity" in some versions]) and Skuld ("Future" [or "Being" in some versions]). All three Norns live at the Well of Urd in Asgard. According to Norse mythology, nothing lasts forever, and even the great Yggdrasil has been said to decay one day. The Norns try to stop or slow this process by pouring mud and water from the Well of Urd over its branches. The magical liquid stops the decaying process for a short time.
|
||||
|
||||
## Relevance to the Service
|
||||
## Relevance to the Service
|
||||
|
||||
Yggdrasil is a knowledge repository for the AniNIX -- it literally "holds the worlds" for the network's data content.
|
||||
|
||||
@ -40,10 +40,10 @@ LDAP in Emby world is controlled by a dotnet plugin. Bind DN, search filters, an
|
||||
|
||||
|
||||
# Available Clients
|
||||
### Music, Pictures, and Video
|
||||
### Music, Pictures, and Video
|
||||
* You can go to [https://aninix.net/yggdrasil the web-app] for a web-accessible view of the service.
|
||||
* Android users can use a specific [https://play.google.com/store/apps/details?id=com.mb.android app].
|
||||
### Books and Other Media
|
||||
### Books and Other Media
|
||||
* Windows users can use [https://winscp.net/eng/download.php WinSCP]. The AniNIX contains a cached copy of this in [https://aninix.net/wolfpack/ WolfPack].[[Category:CachedClient]]
|
||||
* Mac users have a native client.
|
||||
* Linux users should install the openssh client -- see [[SSH#Available clients]] for details.
|
||||
|
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 {} \;
|
@ -5,6 +5,8 @@
|
||||
package:
|
||||
name:
|
||||
- emby-server
|
||||
- perl-image-exiftool
|
||||
- ffmpeg
|
||||
|
||||
- name: Yggdrasil directories
|
||||
become: yes
|
||||
@ -15,16 +17,16 @@
|
||||
group: http
|
||||
mode: 2750
|
||||
loop:
|
||||
- /srv/yggdrasil
|
||||
- /srv/yggdrasil/Digital_Library
|
||||
- /srv/yggdrasil/Music
|
||||
- /srv/yggdrasil/Videos
|
||||
- /srv/yggdrasil/Videos/Shows
|
||||
- /srv/yggdrasil/Videos/Movies
|
||||
- /srv/yggdrasil/Software
|
||||
- /home/yggdrasil
|
||||
- /home/yggdrasil/Digital_Library
|
||||
- /home/yggdrasil/Music
|
||||
- /home/yggdrasil/Videos
|
||||
- /home/yggdrasil/Videos/Shows
|
||||
- /home/yggdrasil/Videos/Movies
|
||||
- /home/yggdrasil/Software
|
||||
|
||||
- name: LiveTV channels
|
||||
command: /bin/bash -c "curl -s https://raw.githubusercontent.com/iptv-org/iptv/master/streams/us.m3u | egrep -A 1 '{{ iptv_location }}' 2>&1 | egrep -v '^--$'"
|
||||
command: /bin/bash -c "curl -s https://raw.githubusercontent.com/iptv-org/iptv/master/streams/us.m3u | grep -A 1 -E '{{ iptv_location }}' 2>&1 | grep -vE '^--$'"
|
||||
register: livetv_channels
|
||||
|
||||
- name: Write to file
|
||||
|
Loading…
Reference in New Issue
Block a user