diff --git a/INFO b/INFO index 76bba69..617194a 100644 --- a/INFO +++ b/INFO @@ -1,5 +1,5 @@ package="openHAB2" -version="2.2.0.003-SNAPSHOT" +version="2.2.0.004-SNAPSHOT" maintainer="openHAB.org" maintainer_url="http://openhab.org/" distributor="cniweb, tim, dieter, dominic, schoppax" @@ -12,4 +12,4 @@ helpurl="https://community.openhab.org/" package_icon="PACKAGE_ICON.PNG" package_icon_120="PACKAGE_ICON_120.PNG" startable="yes" -changelog="2.2.0.003-SNAPSHOT 18.07.2017: Fix public folder,2.2.0.002-SNAPSHOT 12.07.2017: Update from openHAB 2.1.0.007,02.07.2017: Update to openHAB 2.2.0-SNAPSHOT,2.1.0.004-SNAPSHOT 13.03.2017: Update to openHAB 2.1.0-SNAPSHOT,2.1.0.003-SNAPSHOT 06.02.2017: Update to openHAB 2.1.0-SNAPSHOT,2.1.0.002-SNAPSHOT 30.01.2017: Update to openHAB 2.1.0-SNAPSHOT,2.1.0.001-SNAPSHOT 24.01.2017: Update to openHAB 2.1.0-SNAPSHOT,2.0.0.008-SNAPSHOT 10.11.2016: Update to openHAB 2.0.0-SNAPSHOT,2.0.0.007-SNAPSHOT 23.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.006-SNAPSHOT 23.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.005-SNAPSHOT 20.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.004-SNAPSHOT 09.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.003-beta3 02.06.2016: Update to openHAB 2.0.0-beta3;2.0.0.002-beta2 14.02.2016: Update to openHAB 2.0.0-beta2;2.0.0.001-beta1 31.01.2016: Update to openHAB 2.0.0-beta1" +changelog="2.2.0.004-SNAPSHOT 20.07.2017: Fix public folder permissions, replace 7z with tar and backup fix,2.2.0.003-SNAPSHOT 18.07.2017: Fix public folder,2.2.0.002-SNAPSHOT 12.07.2017: Update from openHAB 2.1.0.007,02.07.2017: Update to openHAB 2.2.0-SNAPSHOT,2.1.0.004-SNAPSHOT 13.03.2017: Update to openHAB 2.1.0-SNAPSHOT,2.1.0.003-SNAPSHOT 06.02.2017: Update to openHAB 2.1.0-SNAPSHOT,2.1.0.002-SNAPSHOT 30.01.2017: Update to openHAB 2.1.0-SNAPSHOT,2.1.0.001-SNAPSHOT 24.01.2017: Update to openHAB 2.1.0-SNAPSHOT,2.0.0.008-SNAPSHOT 10.11.2016: Update to openHAB 2.0.0-SNAPSHOT,2.0.0.007-SNAPSHOT 23.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.006-SNAPSHOT 23.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.005-SNAPSHOT 20.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.004-SNAPSHOT 09.10.2016: Update to openHAB 2.0.0-SNAPSHOT;2.0.0.003-beta3 02.06.2016: Update to openHAB 2.0.0-beta3;2.0.0.002-beta2 14.02.2016: Update to openHAB 2.0.0-beta2;2.0.0.001-beta1 31.01.2016: Update to openHAB 2.0.0-beta1" diff --git a/PKG_DEPS b/PKG_DEPS index 39e3e45..1f36e4e 100644 --- a/PKG_DEPS +++ b/PKG_DEPS @@ -1 +1 @@ -pkg_min_ver=6.0 +pkg_min_ver=4.0 diff --git a/scripts/installer.sh b/scripts/installer.sh index d06f972..9ea06d8 100644 --- a/scripts/installer.sh +++ b/scripts/installer.sh @@ -4,7 +4,7 @@ #--------package based on work from pcloadletter.co.uk DOWNLOAD_PATH="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target" -DOWNLOAD_FILE1="openhab-2.2.0-SNAPSHOT.zip" +DOWNLOAD_FILE1="openhab-2.2.0-SNAPSHOT.tar.gz" # Add more files by separating them using spaces INSTALL_FILES="${DOWNLOAD_PATH}/${DOWNLOAD_FILE1}" @@ -14,6 +14,7 @@ EXTRACTED_FOLDER="openHAB-2.2.0-SNAPSHOT" DAEMON_USER="$(echo ${SYNOPKG_PKGNAME} | awk {'print tolower($_)'})" DAEMON_PASS="$(openssl rand 12 -base64 2>nul)" DAEMON_ID="${SYNOPKG_PKGNAME} daemon user" +DAEMON_ACL="user:${DAEMON_USER}:allow:rwxpdDaARWc--:fd--" ENGINE_SCRIPT="start.sh" PIDFILE="/var/services/homes/${DAEMON_USER}/.daemon.pid" @@ -23,9 +24,11 @@ TEMP_FOLDER="$(find / -maxdepth 2 -name '@tmp' | head -n 1)" PRIMARY_VOLUME="$(echo ${TEMP_FOLDER} | grep -oP '^/[^/]+')" PUBLIC_FOLDER="$(synoshare --get public | grep -oP 'Path.+\[\K[^]]+')" +PUBLIC_OH_FOLDERS_EXISTS=no PUBLIC_CONF="${PUBLIC_FOLDER}/openHAB2/conf" PUBLIC_ADDONS="${PUBLIC_FOLDER}/openHAB2/addons" -TIMESTAMP=`date +%Y%m%d_%H%M%S`; +TIMESTAMP="$(date +%Y%m)" +BACKUP_FOLDER="${SYNOPKG_PKGDEST}-backup-$TIMESTAMP" preinst () { @@ -99,7 +102,8 @@ postinst () #extract main archive echo "Install new version" cd ${TEMP_FOLDER} - 7z x ${TEMP_FOLDER}/${DOWNLOAD_FILE1} -o${EXTRACTED_FOLDER} && rm ${TEMP_FOLDER}/${DOWNLOAD_FILE1} + mkdir ${EXTRACTED_FOLDER} + tar -xf ${TEMP_FOLDER}/${DOWNLOAD_FILE1} -C ${EXTRACTED_FOLDER} && rm ${TEMP_FOLDER}/${DOWNLOAD_FILE1} mv ${TEMP_FOLDER}/${EXTRACTED_FOLDER}/* ${SYNOPKG_PKGDEST} rmdir ${TEMP_FOLDER}/${EXTRACTED_FOLDER} chmod +x ${SYNOPKG_PKGDEST}/${ENGINE_SCRIPT} @@ -107,28 +111,38 @@ postinst () echo "Create conf/addon links" #if configdir exists in public folder -> create a symbolic link if [ -d ${PUBLIC_CONF} ]; then - mv ${SYNOPKG_PKGDEST}/conf/* ${PUBLIC_CONF} + PUBLIC_OH_FOLDERS_EXISTS=yes + mv -u ${SYNOPKG_PKGDEST}/conf/* ${PUBLIC_CONF} rm -r ${SYNOPKG_PKGDEST}/conf ln -s ${PUBLIC_CONF} ${SYNOPKG_PKGDEST} - chmod -R u+w ${PUBLIC_CONF} + synoacltool -get ${PUBLIC_CONF} | grep -F ${DAEMON_ACL} > /dev/null || synoacltool -add ${PUBLIC_CONF} ${DAEMON_ACL} fi #if public addons dir exists in public folder -> create a symbolic link if [ -d ${PUBLIC_ADDONS} ]; then - mv ${SYNOPKG_PKGDEST}/addons/* ${PUBLIC_ADDONS} + PUBLIC_OH_FOLDERS_EXISTS=yes + mv -u ${SYNOPKG_PKGDEST}/addons/* ${PUBLIC_ADDONS} rm -r ${SYNOPKG_PKGDEST}/addons ln -s ${PUBLIC_ADDONS} ${SYNOPKG_PKGDEST} - chmod -R u+w ${PUBLIC_ADDONS} + synoacltool -get ${PUBLIC_ADDONS} | grep -F ${DAEMON_ACL} > /dev/null || synoacltool -add ${PUBLIC_ADDONS} ${DAEMON_ACL} fi #add log file mkdir -p ${SYNOPKG_PKGDEST}/userdata/logs touch ${SYNOPKG_PKGDEST}/userdata/logs/openhab.log - + + # Restore UserData if exists + if [ -d ${BACKUP_FOLDER} ]; then + cp -arf ${BACKUP_FOLDER}/userdata ${SYNOPKG_PKGDEST}/ + fi + #change owner of folder tree echo "Fix permissions" - chown -hR ${DAEMON_USER} ${PUBLIC_CONF} - chown -hR ${DAEMON_USER} ${PUBLIC_ADDONS} + if [ $PUBLIC_OH_FOLDERS_EXISTS == yes ]; then + synoshare --setuser public RO + ${DAEMON_USER} + chown -hR ${DAEMON_USER} ${PUBLIC_CONF} + chown -hR ${DAEMON_USER} ${PUBLIC_ADDONS} + fi chown -hR ${DAEMON_USER} ${SYNOPKG_PKGDEST} chmod -R u+w ${SYNOPKG_PKGDEST}/userdata @@ -139,6 +153,8 @@ postinst () if [ -d /dev/ttyACM1 ]; then chmod 777 /dev/ttyACM1 fi + + echo "Installation done." > $SYNOPKG_TEMP_LOGFILE; exit 0 } @@ -171,7 +187,7 @@ postuninst () else echo "Daemon user folder '${DAEMON_HOME}' not found - nothing deleted" fi - + exit 0 } @@ -184,56 +200,45 @@ preupgrade () rm -f $PIDFILE fi sleep 10 - - # Remove tmp, logs & cache dirs + + # Remove tmp, logs, cache and runtime dirs if [ -d ${SYNOPKG_PKGDEST}/userdata/tmp ]; then - echo "Remove tmp" rm -rf ${SYNOPKG_PKGDEST}/userdata/tmp fi if [ -d ${SYNOPKG_PKGDEST}/userdata/cache ]; then - echo "Remove cache" rm -rf ${SYNOPKG_PKGDEST}/userdata/cache fi if [ -d ${SYNOPKG_PKGDEST}/userdata/log ]; then - echo "Remove log" rm -rf ${SYNOPKG_PKGDEST}/userdata/log fi if [ -d ${SYNOPKG_PKGDEST}/userdata/logs ]; then - echo "Remove logs" rm -rf ${SYNOPKG_PKGDEST}/userdata/logs fi - - # backup current installation with settings - echo "Backup" - mv ${SYNOPKG_PKGDEST} /${SYNOPKG_PKGDEST}-backup-$TIMESTAMP - - echo "Get new version" - cd ${TEMP_FOLDER} - # go through list of files - for WGET_URL in ${INSTALL_FILES}; do - WGET_FILENAME="$(echo ${WGET_URL} | sed -r "s%^.*/(.*)%\1%")" - echo "Processing ${WGET_FILENAME}" - [ -f "${TEMP_FOLDER}/${WGET_FILENAME}" ] && rm ${TEMP_FOLDER}/${WGET_FILENAME} - # use local file first - if [ -f "${PUBLIC_FOLDER}/${WGET_FILENAME}" ]; then - echo "Found file locally - copying" - cp ${PUBLIC_FOLDER}/${WGET_FILENAME} ${TEMP_FOLDER} - else - wget -nv --no-check-certificate --output-document=${WGET_FILENAME} ${WGET_URL} - if [[ $? != 0 ]]; then - echo "There was a problem downloading ${WGET_FILENAME} from the download link:" - echo "'${WGET_URL}'" - echo "Alternatively, download this file manually and place it in the 'public' shared folder and start installation again." - if [ -z "${PUBLIC_FOLDER}" ];then - echo "Note: You must create a 'public' shared folder first on your primary volume" - fi - exit 1 - fi - fi - done + + if [ -d ${SYNOPKG_PKGDEST}/runtime ]; then + rm -rf ${SYNOPKG_PKGDEST}/runtime + fi + + # Remove openHAB system files... + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/all.policy + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/branding.properties + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/branding-ssh.properties + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/config.properties + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/custom.properties + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/version.properties + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/distribution.info + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/jre.properties + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/profile.cfg + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/startup.properties + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/org.apache.karaf* + rm -f ${SYNOPKG_PKGDEST}/userdata/etc/org.ops4j.pax.url.mvn.cfg + + # Create backup + mkdir -p ${BACKUP_FOLDER}/userdata + mv ${SYNOPKG_PKGDEST}/userdata/* ${BACKUP_FOLDER}/userdata exit 0 } @@ -241,45 +246,10 @@ preupgrade () postupgrade () { - #extract main archive - echo "Install new version" - cd ${TEMP_FOLDER} - 7z x ${TEMP_FOLDER}/${DOWNLOAD_FILE1} -o${EXTRACTED_FOLDER} && rm ${TEMP_FOLDER}/${DOWNLOAD_FILE1} - mv ${TEMP_FOLDER}/${EXTRACTED_FOLDER}/* ${SYNOPKG_PKGDEST} - rmdir ${TEMP_FOLDER}/${EXTRACTED_FOLDER} - chmod +x ${SYNOPKG_PKGDEST}/${ENGINE_SCRIPT} - - # restore configuration and userdata - echo "Restore UserData" - cp -ar ${SYNOPKG_PKGDEST}-backup-$TIMESTAMP/userdata ${SYNOPKG_PKGDEST}/ - - echo "Create conf/addon links" - #if configdir exists in public folder -> create a symbolic link - if [ -d ${PUBLIC_CONF} ]; then - mv ${SYNOPKG_PKGDEST}/conf/* ${PUBLIC_CONF} - rm -r ${SYNOPKG_PKGDEST}/conf - ln -s ${PUBLIC_CONF} ${SYNOPKG_PKGDEST} - chmod -R u+w ${PUBLIC_CONF} - fi - - #if public addons dir exists in public folder -> create a symbolic link - if [ -d ${PUBLIC_ADDONS} ]; then - mv ${SYNOPKG_PKGDEST}/addons/* ${PUBLIC_ADDONS} - rm -r ${SYNOPKG_PKGDEST}/addons - ln -s ${PUBLIC_ADDONS} ${SYNOPKG_PKGDEST} - chmod -R u+w ${PUBLIC_ADDONS} - fi - - #add log file - mkdir -p ${SYNOPKG_PKGDEST}/userdata/logs - touch ${SYNOPKG_PKGDEST}/userdata/logs/openhab.log - - # fix permissions - echo "Fix permissions" - chown -hR ${DAEMON_USER} ${PUBLIC_CONF} - chown -hR ${DAEMON_USER} ${PUBLIC_ADDONS} - chown -hR ${DAEMON_USER} ${SYNOPKG_PKGDEST} - chmod -R u+w ${SYNOPKG_PKGDEST}/userdata - + # Remove all backups after installation + rm -rf ${SYNOPKG_PKGDEST}-backup* + + echo "Update done." > $SYNOPKG_TEMP_LOGFILE + exit 0 } diff --git a/scripts/start-stop-status.sh b/scripts/start-stop-status.sh index 0b1d4e5..f00d093 100644 --- a/scripts/start-stop-status.sh +++ b/scripts/start-stop-status.sh @@ -26,13 +26,13 @@ case $1 in #set the current timezone for Java so that log timestamps are accurate #we need to use the modern timezone names so that Java can figure out DST - SYNO_TZ=`cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'"'` - #fix for DST time in DSM 5.2 thanks to MinimServer Syno package author - [ -e /usr/share/zoneinfo/Timezone/synotztable.json ] \ - && SYNO_TZ=`jq ".${SYNO_TZ} | .nameInTZDB" /usr/share/zoneinfo/Timezone/synotztable.json | sed -e "s/\"//g"` \ - || SYNO_TZ=`grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzname | sed -e "s/^.*= //"` - #Before DSM 5.1 - #SYNO_TZ=grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzlist | sed -e "s/^.*= //" + if [ -n "$SYNOPKG_DSM_VERSION_MAJOR" -a $SYNOPKG_DSM_VERSION_MAJOR -ge 6 ]; then + SYNO_TZ=$(cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'"') + else + [ -e /usr/share/zoneinfo/Timezone/synotztable.json ] \ + && SYNO_TZ=$(jq ".${SYNO_TZ} | .nameInTZDB" /usr/share/zoneinfo/Timezone/synotztable.json | sed -e "s/\"//g") \ + || SYNO_TZ=$(grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzname | sed -e "s/^.*= //") + fi grep "^export TZ" ${DAEMON_HOME}/.profile > /dev/null \ && sed -i "s%^export TZ=.*$%export TZ='${SYNO_TZ}'%" ${DAEMON_HOME}/.profile \ || echo export TZ=\'${SYNO_TZ}\' >> ${DAEMON_HOME}/.profile