3 Commits

6 changed files with 56 additions and 11 deletions

View File

@ -2,7 +2,7 @@
<div class="controls" v-if="display">
<i class="off-icon" v-on:click="action('shutdown')" v-if="off_available"></i>
<i class="quit-icon" v-on:click="action('quit')" v-if="quit_available"></i>
<i :class="[ update_available ? 'update-icon' :'no-update-icon' ]" v-if="update_possibe" @click="$router.push({ name: 'update' })"></i>
<i :class="[ update_available ? 'update-icon' :'no-update-icon' ]" @click="$router.push({ name: 'update' })"></i>
</div>
</template>
<script>
@ -39,7 +39,7 @@ export default {
this.update_available = false
this.update_possible = true
}
} else {
} else {
this.update_possible = false
}
})

View File

@ -50,7 +50,8 @@ frontend:
sparklines: true
virtual_keyboard: true
user_lang: userlang
update: updateoption
# NETWORK -
# Some elements related to the network configuration, such as
# the interfaces (updated during the install), the list of SSIDs

View File

@ -97,6 +97,19 @@ set_kioskmode() {
fi
}
set_update() {
echo -n "[?] Do you want to be able to update TinyCheck from the frontend interface? [Yes/No] "
read answer
if [[ "$answer" =~ ^([yY][eE][sS]|[yY])$ ]]
then
sed -i "s/updateoption/true/g" /usr/share/tinycheck/config.yaml
echo -e "\e[92m [✔] You'll be able to update it from the frontend!\e[39m"
else
sed -i "s/updateoption/false/g" /usr/share/tinycheck/config.yaml
echo -e "\e[92m [✔] You'll need to pass by the console script to update TinyCheck.\e[39m"
fi
}
create_directory() {
# Create the TinyCheck directory and move the whole stuff there.
echo -e "[+] Creating TinyCheck folder under /usr/share/"

View File

@ -13,6 +13,12 @@ def check():
return jsonify(Update().check_version())
@update_bp.route("/get-version", methods=["GET"])
def get_version():
""" Check the current version """
return jsonify(Update().get_current_version())
@update_bp.route("/process", methods=["GET"])
def process():
""" Check the presence of new version """

View File

@ -20,7 +20,8 @@ class Update(object):
"""
Check if a new version of TinyCheck is available
by quering the Github api and comparing the last
tag with the VERSION file content.
tag inside the VERSION file.
:return: dict containing the available versions.
"""
if read_config(("frontend", "update")):
try:
@ -30,21 +31,41 @@ class Update(object):
with open(os.path.join(self.app_path, "VERSION")) as f:
if f.read() != res[0]["name"]:
return {"status": True,
"message": "A new version is available"}
"message": "A new version is available",
"current_version": f.read(),
"next_version": res[0]["name"]}
else:
return {"status": True,
"message": "This is the latest version"}
"message": "This is the latest version",
"current_version": f.read()}
except:
return {"status": False,
"message": "Something went wrong (no internet nor version file)"}
"message": "Something went wrong (no API access nor version file)"}
else:
return {"status": False,
"message": "You don't have rights to do this operation."}
def get_current_version(self):
"""
Get the current version of the TinyCheck instance
:return: dict containing the current version or error.
"""
if read_config(("frontend", "update")):
try:
with open(os.path.join(self.app_path, "VERSION")) as f:
return {"status": True,
"current_version": f.read()}
except:
return {"status": False,
"message": "Something went wrong - no version file ?"}
else:
return {"status": False,
"message": "You don't have rights to do this operation."}
def update_instance(self):
"""
Update the instance by executing
the update script.
Update the instance by executing the update script.
:return: dict containing the update status.
"""
if read_config(("frontend", "update")):
try:

View File

@ -7,7 +7,7 @@ fi
if [ $PWD = "/usr/share/tinycheck" ]; then
echo "[+] Cloning the current repository to /tmp/"
rm -rf /tmp/tinycheck/ &> /dev/null
cd /tmp/ && git clone https://github.com/KasperskyLab/tinycheck
cd /tmp/ && git clone --branch update-feature https://github.com/KasperskyLab/tinycheck
cd /tmp/tinycheck && bash update.sh
elif [ $PWD = "/tmp/tinycheck" ]; then
@ -61,6 +61,10 @@ elif [ $PWD = "/tmp/tinycheck" ]; then
sed -i 's/analysis:/analysis:\n active: true/g' /usr/share/tinycheck/config.yaml
fi
if ! grep -q update /usr/share/tinycheck/config.yaml; then
sed -i 's/frontend:/frontend:\n update: true/g' /usr/share/tinycheck/config.yaml
fi
if ! grep -q "CN=R3,O=Let's Encrypt,C=US" /usr/share/tinycheck/config.yaml; then
sed -i "s/free_issuers:/free_issuers:\n - CN=R3,O=Let's Encrypt,C=US/g" /usr/share/tinycheck/config.yaml
fi
@ -71,7 +75,7 @@ elif [ $PWD = "/tmp/tinycheck" ]; then
service tinycheck-watchers restart
echo "[+] Updating the TinyCheck version"
cd /tmp/tinycheck && git tag | tail -n 1 > /usr/share/tinycheck/VERSION
cd /tmp/tinycheck && git tag | tail -n 1 | xargs echo -n > /usr/share/tinycheck/VERSION
echo "[+] TinyCheck updated!"
fi