Run Cubbit on start up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (c) <2020> <DangerBlack> | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# The above copyright notice and this permission notice shall be included in all | |
# copies or substantial portions of the Software. | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
# Installation instruction | |
# link this script to your user account after boot of your machine to start cubbit at boot. | |
# https://help.ubuntu.com/stable/ubuntu-help/startup-applications.html.en | |
download_folder=$(xdg-user-dir DOWNLOAD) | |
config_path=$(echo $HOME/.config/cubbit_cache) | |
previous_version=$(cat "$config_path/cubbit_version.txt") | |
echo "[1] Check for cubbit version." | |
if test -f "$download_folder/$previous_version"; then | |
echo "[2] Running $previous_version that already exists." | |
$download_folder/$previous_version --no-sandbox | |
else | |
echo "[2] Downloding last version name." | |
source=$(curl 'https://get.cubbit.io/desktop/linux/latest-linux.yml?script=linux&version=0.0.1') | |
exec_name=$(echo "$source" | grep 'url' | awk 'BEGIN { ORS=" " }; {print $3}'|tr -d '[:space:]') | |
echo "[3] Check if last Cubbit version exists." | |
if test -f "$download_folder/$exec_name"; then | |
echo "[4] Storing new version name in $config_path" | |
mkdir -p $config_path | |
echo "$exec_name" > "$config_path/cubbit_version.txt" | |
echo "[5] Running $exec_name." | |
$download_folder/$exec_name --no-sandbox | |
else | |
echo "[2] Error $exec_name does not exists in $download_folder." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment