grocy - Adapt to new sequencer options

This commit is contained in:
2022-06-11 09:45:18 +02:00
parent ad93a5eb9c
commit 54cfcef9f1

View File

@@ -8,30 +8,22 @@ readonly versionUrl="https://api.github.com/repos/grocy/grocy/releases/latest"
versionNew= versionNew=
versionNow= versionNow=
sc_grocyConf= sc_grocyConf=
sc_grocyBackup="data/backup" sc_grocyBackup="data/backup"
sc_grocyViewcache="data/viewcache" sc_grocyViewcache="data/viewcache"
grocyDownLoc="/tmp/grocy_latest.zip" sq_grocyDownLoc="/tmp/grocy_latest.zip"
# Get script working directory
# (when called from a different directory and even when called via symlink)
readonly sq_dir="$(cd "$(dirname -- "$(realpath ${BASH_SOURCE[0]})")" >>/dev/null 2>&1 && pwd)"
readonly sq_scriptFile=$(basename -- $0)
readonly sq_scriptName=${sq_scriptFile%%.*}
readonly sq_configFileName="${sq_scriptName}.cfg"
readonly sq_configFileTemplate="$sq_dir/${sq_configFileName}.example"
sq_aptOpt= sq_aptOpt=
sq_config=0 sq_config=0
seq_config() { seq_config() {
initSeqConfig -p "$sq_scriptName" "$sq_configFileTemplate" initSeqConfig -p "$seq_fileName" "$seq_configTemplate"
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
sq_config=1 sq_config=1
else else
# End if no configuration file exists # End if no configuration file exists
dry || return -1 dry || return 1
fi fi
# config not sourced if only profiles should be listed # config not sourced if only profiles should be listed
@@ -49,7 +41,7 @@ getVersions() {
versionNow=${versionNow:-$(grep -Po '"Version": "\K.*?(?=")' 2>/dev/null < "${sc_grocyDir}/version.json")} versionNow=${versionNow:-$(grep -Po '"Version": "\K.*?(?=")' 2>/dev/null < "${sc_grocyDir}/version.json")}
} }
step_1_info() { step_1_info() {
echo "Check $toolName status" echo "Check $toolName status"
echoinfo "Returns 1 if update is available" echoinfo "Returns 1 if update is available"
} }
@@ -57,17 +49,17 @@ step_1_alias() { echo "status"; }
step_1() { step_1() {
getVersions getVersions
if [ -e "${sc_grocyDir}" ] ; then if [ -e "${sc_grocyDir}" ] ; then
echo info
echo "$toolName installed" info "$toolName installed"
echo " at: ${sc_grocyDir}" info -a " at: ${sc_grocyDir}"
echo " version: ${versionNow}" info -a " version: ${versionNow}"
echo " config: ${sc_grocyConf}" info -a " config: ${sc_grocyConf}"
echo -n " update: " info -an " update: "
if [[ ! ${versionNow} = ${versionNew} ]] ; then if [[ ! ${versionNow} = ${versionNew} ]] ; then
echo "available: ${versionNew}}" info -d "available: ${versionNew}"
return 1 return 1
else else
echo "already on latest" info -d "already on latest"
return 0 return 0
fi fi
else else
@@ -102,14 +94,14 @@ step_22() {
info "Installing $toolName version ${versionNew}" info "Installing $toolName version ${versionNew}"
fi fi
fi fi
exe wget ${downUrl} -q -O "${grocyDownLoc}" exe wget ${downUrl} -q -O "${sq_grocyDownLoc}"
endReturn -o $? "Download failed" endReturn -o $? "Download failed"
if [ -e "${sc_grocyDir}" ] ; then if [ -e "${sc_grocyDir}" ] ; then
step backup step backup
exe rm -rf "${sc_grocyDir}/${sc_grocyViewcache}" exe rm -rf "${sc_grocyDir}/${sc_grocyViewcache}"
fi fi
exe rm -rf "${sc_grocyDir}/"!(data) exe rm -rf "${sc_grocyDir}/"!(data)
exe unzip -o -qq "${grocyDownLoc}" -d "${sc_grocyDir}" exe unzip -o -qq "${sq_grocyDownLoc}" -d "${sc_grocyDir}"
exe chown -R www-data: "${sc_grocyDir}/public" "${sc_grocyDir}/data" exe chown -R www-data: "${sc_grocyDir}/public" "${sc_grocyDir}/data"
# Populate first config # Populate first config
if [ ! -e "${sc_grocyConf}" ] ; then if [ ! -e "${sc_grocyConf}" ] ; then
@@ -131,7 +123,7 @@ step_30() {
* Proxy pass from a subdirectory (e.g. domain.me/grocy) * Proxy pass from a subdirectory (e.g. domain.me/grocy)
* [data/config.php] * [data/config.php]
Setting('BASE_PATH', ''); Setting('BASE_PATH', '');
Setting('BASE_URL', 'https://domain.me/grocy'); Setting('BASE_URL', 'https://domain.me/grocy');
# Nginx config # Nginx config
server { server {