summarylogtreecommitdiffstats
path: root/headphones.install
diff options
context:
space:
mode:
Diffstat (limited to 'headphones.install')
-rw-r--r--headphones.install52
1 files changed, 29 insertions, 23 deletions
diff --git a/headphones.install b/headphones.install
index 312d6c245c0c..2dfb8347452d 100644
--- a/headphones.install
+++ b/headphones.install
@@ -1,29 +1,35 @@
-_NAME=headphones
+post_upgrade() {
+ if (( $(vercmp "0.5.18.r159.gda9287d7-2" "$2") > 0 )); then
+ if [[ -f /opt/headphones/config.ini && ! -f /var/lib/headphones/config.ini ]]; then
+ cp -a /opt/headphones/config.ini /var/lib/headphones/
+ echo "Copied config.ini from /opt/headphones/ -> /var/lib/headphones/"
+ fi
-post_install() {
- getent passwd ${_NAME} > /dev/null || useradd -d /opt/${_NAME} -s /bin/false -r ${_NAME} > /dev/null
- chown -R ${_NAME}. /opt/${_NAME}
+ if [[ -f /opt/headphones/headphones.db && ! -f /var/lib/headphones/headphones.db ]]; then
+ cp -a /opt/headphones/headphones.db /var/lib/headphones/
+ echo "Copied headphones.db from /opt/headphones/ -> /var/lib/headphones/"
+ fi
- # Create a directory in /run if it does not exist
- if [ ! -d /run/${_NAME} ]; then
- mkdir /run/${_NAME}
- chown ${_NAME}. /run/${_NAME}
- chmod 775 /run/${_NAME}
- fi
+ if [[ -d /opt/headphones/logs && ! -d /var/lib/headphones/logs ]]; then
+ cp -a /opt/headphones/logs /var/lib/headphones/
+ echo "Copied logs from /opt/headphones/ -> /var/lib/headphones/"
+ fi
- echo ""
- echo "To fill the configuration file (/opt/headphones/config.ini), do:"
- echo " systemctl start headphones; systemctl stop headphones"
- echo ""
- echo "It should dump the initial configuration that you can now modify."
- echo ""
-}
+ if [[ -d /opt/headphones/cache && ! -d /var/lib/headphones/cache ]]; then
+ cp -a /opt/headphones/cache /var/lib/headphones/
+ echo "Copied cache from /opt/headphones/ -> /var/lib/headphones/"
+ fi
+ fi
-post_upgrade() {
- post_install
-}
+ if [[ "$( getent passwd headphones | cut -d: -f6 )" != "/var/lib/headphones" ]]; then
+ usermod -d /var/lib/headphones headphones
+ if [[ $? -ne 0 ]]; then
+ echo "Could not change headphones users home directory."
+ echo "Run: sudo systemctl stop headphones ; sudo usermod -d /var/lib/headphones headphones ; sudo systemctl start headphones"
+ fi
+ fi
-post_remove() {
- echo "Some files have not been removed because they are created by ${_NAME} itself, e.g. the music database."
- userdel -f ${_NAME}
+ if [[ -d /opt/lazylibrarian ]]; then
+ echo "Remove /opt/lazylibrarian if everything is working correctly from /var/lib/lazylibrarian now."
+ fi
}