#!/bin/sh # config helper ## run this script as bellow to set your radio domain ## sudo RADIO="https://meraklis.ddns.com" sh /usr/src/mympd/config-helper.sh MUID=288 MGID=288 USERNAME=mympd GROUPNAME=mympd COMMENT=mympd LOGINSHELL=/usr/bin/false DIR=mympd RADIO=${RADIO:-https://meraklis.ddns.net} PORT=8081 echo "" echo "This script tries to create:" echo "user $USERNAME with user id $MUID" echo "group $GROUPNAME with group id $MGID" echo "If the user or group id already exists, it automatically tries higher ids." echo "" echo "After that it creates the needed directories with proper permissions, too." echo "" echo "Hit ENTER to continue (CTRL+C to cancel)" read JUNK echo "" if grep -qe "^$GROUPNAME:" /etc/group; then echo "group $GROUPNAME already exists. Exiting..." exit 1 fi if grep -qe "^$USERNAME:" /etc/passwd; then echo "user $USERNAME already exists. Exiting..." exit 1 fi mympd -c /var/lib/mympd/config NEXTGID="$(MGID=$MGID awk -F: '{uid[$3]=1} END { for (i=ENVIRON["MGID"];i in uid;i++);print i}' /etc/group)" echo creating group $GROUPNAME with GID $NEXTGID... /usr/sbin/groupadd -g $NEXTGID $GROUPNAME # if nscd is running update group cache [ $(pidof nscd) ] && { nscd --invalidate group; } NEXTUID="$(MUID=$MUID awk -F: '{uid[$3]=1} END { for (i=ENVIRON["MUID"];i in uid;i++);print i}' /etc/passwd)" echo creating user $USERNAME with UID $NEXTUID... /usr/sbin/useradd -g $GROUPNAME -u $NEXTUID -d /var/lib/$DIR -c $COMMENT -s $LOGINSHELL $USERNAME # if nscd is running update user cache [ $(pidof nscd) ] && { nscd --invalidate passwd; } echo creating /var/lib/$DIR mkdir -p /var/lib/$DIR/config /var/cache/$DIR /usr/sbin/usermod -a -G audio $DIR chown -R $USERNAME:$GROUPNAME /var/lib/$DIR /var/cache/$DIR echo -n "true" > /var/lib/$DIR/config/http echo -n "localhost" > /var/lib/$DIR/config/http_host # Define Port for mympd echo -n $PORT > /var/lib/$DIR/config/http_port echo -n $RADIO > /var/lib/$DIR/config/mympd_uri # Ορισμός του subpath για τον Apache echo -n "/$DIR" > /var/lib/$DIR/config/scriptwebroot echo -n "false" > /var/lib/$DIR/config/cert_check # Απενεργοποίηση εσωτερικού SSL (θα το κάνει ο Apache) echo -n "false" > /var/lib/$DIR/config/ssl echo -n "+127.0.0.0/8" > /var/lib/$DIR/config/scriptacl echo -n "false" > /var/lib/$DIR/config/scripts_external