Bob Mottram 8 gadus atpakaļ
vecāks
revīzija
e4290e3439
1 mainītis faili ar 48 papildinājumiem un 23 dzēšanām
  1. 48
    23
      src/freedombone-app-riot

+ 48
- 23
src/freedombone-app-riot Parādīt failu

@@ -117,8 +117,49 @@ function reconfigure_riot {
117 117
     echo -n ''
118 118
 }
119 119
 
120
+function riot_download {
121
+    # download
122
+    if [ ! -f $INSTALL_DIR/${RIOT_FILENAME}.tar.gz ]; then
123
+        wget ${RIOT_DOWNLOAD_URL}/${RIOT_FILENAME}.tar.gz -O $INSTALL_DIR/${RIOT_FILENAME}.tar.gz
124
+    fi
125
+    if [ ! -f $INSTALL_DIR/${RIOT_FILENAME}.tar.gz ]; then
126
+        echo $'Unable to download Riot Web from releases'
127
+        exit 62836
128
+    fi
129
+    cd $INSTALL_DIR
130
+
131
+    # check the hash
132
+    curr_hash=$(sha256sum ${RIOT_FILENAME}.tar.gz | awk -F ' ' '{print $1}')
133
+    if [[ "$curr_hash" != "$RIOT_HASH" ]]; then
134
+        echo $'Riot download hash does not match'
135
+        exit 78352
136
+    fi
137
+
138
+    tar -xzvf ${RIOT_FILENAME}.tar.gz
139
+    if [ ! -d $INSTALL_DIR/${RIOT_FILENAME} ]; then
140
+        echo $'Unable to extract Riot Web tarball'
141
+        exit 542826
142
+    fi
143
+    cp -r $INSTALL_DIR/${RIOT_FILENAME}/* /var/www/$RIOT_DOMAIN_NAME/htdocs
144
+    chown -R www-data:www-data /var/www/$RIOT_DOMAIN_NAME/htdocs
145
+}
146
+
120 147
 function upgrade_riot {
121
-    set_repo_commit /var/www/$RIOT_DOMAIN_NAME/htdocs "riot commit" "$RIOT_COMMIT" $RIOT_REPO
148
+    if ! grep -q 'riot version:' $COMPLETION_FILE; then
149
+        return
150
+    fi
151
+
152
+    CURR_RIOT_VERSION=$(get_completion_param "riot version")
153
+    echo "riot current version: ${CURR_RIOT_VERSION}"
154
+    echo "riot app version: ${RIOT_VERSION}"
155
+    if [[ "${CURR_RIOT_VERSION}" == "${RIOT_VERSION}" ]]; then
156
+        return
157
+    fi
158
+
159
+    riot_download
160
+    sed -i "s|riot version.*|riot version:$RIOT_VERSION|g" ${COMPLETION_FILE}
161
+
162
+    systemctl restart nginx
122 163
 }
123 164
 
124 165
 function backup_local_riot {
@@ -170,29 +211,8 @@ function install_riot {
170 211
         mkdir $INSTALL_DIR
171 212
     fi
172 213
 
173
-    # download
174
-    if [ ! -f $INSTALL_DIR/${RIOT_FILENAME}.tar.gz ]; then
175
-        wget ${RIOT_DOWNLOAD_URL}/${RIOT_FILENAME}.tar.gz -O $INSTALL_DIR/${RIOT_FILENAME}.tar.gz
176
-    fi
177
-    if [ ! -f $INSTALL_DIR/${RIOT_FILENAME}.tar.gz ]; then
178
-        echo $'Unable to download Riot Web from releases'
179
-        exit 62836
180
-    fi
181
-    cd $INSTALL_DIR
182
-
183
-    # check the hash
184
-    curr_hash=$(sha256sum ${RIOT_FILENAME}.tar.gz | awk -F ' ' '{print $1}')
185
-    if [[ "$curr_hash" != "$RIOT_HASH" ]]; then
186
-        echo $'Riot download hash does not match'
187
-        exit 78352
188
-    fi
214
+    riot_download
189 215
 
190
-    tar -xzvf ${RIOT_FILENAME}.tar.gz
191
-    if [ ! -d $INSTALL_DIR/${RIOT_FILENAME} ]; then
192
-        echo $'Unable to extract Riot Web tarball'
193
-        exit 542826
194
-    fi
195
-    cp -r $INSTALL_DIR/${RIOT_FILENAME}/* /var/www/$RIOT_DOMAIN_NAME/htdocs
196 216
     cd /var/www/$RIOT_DOMAIN_NAME/htdocs
197 217
     cp config.sample.json config.json
198 218
 
@@ -282,6 +302,11 @@ function install_riot {
282 302
     systemctl restart nginx
283 303
 
284 304
     set_completion_param "riot domain" "$RIOT_DOMAIN_NAME"
305
+    if ! grep -q "riot version:" ${COMPLETION_FILE}; then
306
+        echo "riot version:${RIOT_VERSION}" >> ${COMPLETION_FILE}
307
+    else
308
+        sed -i "s|riot version.*|riot version:${RIOT_VERSION}|g" ${COMPLETION_FILE}
309
+    fi
285 310
     APP_INSTALLED=1
286 311
 }
287 312