Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 38 lines (34 sloc) 1.28 KB
#!/bin/sh
# This little script ensures that all files needed by MPD exists
# and has correct permissions.
# It should be run as root, or chown may (and should) fail.
#
# Skrypt który zapewnia, że wszystkie pliki wymagane przez MPD działają
# i mają poprawnie ustawione uprawnienia.
# Powinien być uruchamiany jako superużytkownik, w przeciwnym wypadku
# chown nie zadziała.
#
# Author: Mirosław „Minio” Zalewski <miniopl@gmail.com> http://minio.xt.pl
# License: None
# Last modified: Fri, 03 Aug 2012 16:55:59 +0200
##########################################################################
MPD_CONF=${1:-"/etc/mpd.conf"}
MPD_USER=$(grep -v '^#' "${MPD_CONF}" |sed -n -e '/user/s:.*"\(.\+\)".*:\1:i p')
MPD_GROUP=$(grep -v '^#' "${MPD_CONF}" |sed -n -e '/group/s:.*"\(.\+\)".*:\1:i p')
if [ -z "${MPD_GROUP}" ]; then
MPD_GROUP=audio
fi
grep -v '^#' "${MPD_CONF}" |sed -n -e '/_file/s:.*"\(.\+\)".*:\1:i p'| while read file; do
if [ ! -e "${file}" ]; then
if [ ! -d "$(dirname "${file}")" ]; then
mkdir -pv "$(dirname "${file}")"
fi
touch "${file}"
fi
chmod 755 "${file}"
chown "${MPD_USER}":"${MPD_GROUP}" "${file}"
done
grep -v '^#' "${MPD_CONF}" |sed -n -e '/_dir/s:.*"\(.\+\)".*:\1:i p'| while read dir; do
mkdir -pv "${dir}"
chown "${MPD_USER}":"${MPD_GROUP}" "${dir}"
done