diff --git a/app/src-tauri/Cargo.toml b/app/src-tauri/Cargo.toml index bc421d43d00b715e80e404bcf3b1709c23de0fbc..c28797cb790c395bdc731c54b22600511e5fc694 100755 --- a/app/src-tauri/Cargo.toml +++ b/app/src-tauri/Cargo.toml @@ -23,4 +23,4 @@ reqwest = {version = "0.11", features = ["json"] } [features] default = [ "custom-protocol" ] -custom-protocol = [ "tauri/custom-protocol" ] +custom-protocol = [ "tauri/custom-protocol" ] \ No newline at end of file diff --git a/daemon/src/config.rs b/daemon/src/config.rs index 52b38e3b837f1db973e716d34aacaeb56c555ad0..c62334d517f20033af9c23a2d04037b883d265df 100644 --- a/daemon/src/config.rs +++ b/daemon/src/config.rs @@ -4,7 +4,6 @@ use dirs_next::config_dir; use std::collections::HashMap; - #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(default = "default_daemon_config")] pub struct DaemonConfig { @@ -50,4 +49,4 @@ fn default_daemon_config() -> DaemonConfig { remind_limit: Some(5), log_path: Some(path), } -} \ No newline at end of file +} diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000000000000000000000000000000000000..b51dc0312a345f1d2ba238966470949f27b3a996 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,83 @@ +echo "LibreHomework Installer" +echo "Getting latest version..." + +LATREL=$(curl -L -s -H 'Accept: application/json' https://github.com/HGEpro/LibreHomework/releases/latest) +LATVER=$(echo $LATREL | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') + + +source="https://github.com/HGEpro/LibreHomework/archive/refs/tags/$LATVER.zip" +deb="https://github.com/HGEpro/LibreHomework/releases/download/$LATVER/librehomework_${LATVER}_amd64.deb" +appimage="https://github.com/HGEpro/LibreHomework/releases/download/$LATVER/librehomework_${LATVER}_amd64.AppImage" + +bin_types=("Source" "Debian Package" "AppImage" "Skip to daemon installation") +select bin in "${bin_types[@]}"; do + case $bin in + "Source") + echo "Downloading zip file..." + curl -L -s $source -o "LibreHomework-Source_${LATVER}.zip" + echo "Extracting zip file..." + unzip "LibreHomework-Source_${LATVER}.zip" > /dev/null + echo "Done, you can now compile it by typing cd LibreHomework-Source_${LATVER} && npm i && npm run tauri build" + break + ;; + "Debian Package") + echo "Downloading debian package..." + curl -L -s $deb -o "LibreHomework_${LATVER}.deb" + echo "Enter the password to install the package:" + sudo dpkg -i "LibreHomework_${LATVER}.deb" > /dev/null + echo "Done, you can now launch it from the menu or the command line with libre-homework" + break + ;; + "AppImage") + echo "Downloading AppImage..." + curl -L -s $appimage -o "LibreHomework_${LATVER}.AppImage" + chmod +x "LibreHomework_${LATVER}.AppImage" + echo "Done, you can now run it by typing ./LibreHomework_${LATVER}.AppImage" + break + ;; + "Skip to daemon installation") + echo "No binary has been downloaded" + break + ;; + *) echo "Invalid option $REPLY";; + esac +done + +echo "Do you want to download, install and configure the daemon? (y/n)" +read daemon +if [ $daemon = "y" ]; then + echo "Downloading daemon executable..." + curl -L -s "https://github.com/HGEpro/LibreHomework/releases/download/${LATVER}/librehomework-daemon_v1.0.0_amd64" -o "librehomework-daemon_${LATVER}_amd64" + sudo mv "librehomework-daemon_${LATVER}_amd64" /usr/bin/librehomeworkd + sudo chmod +x /usr/bin/librehomeworkd + + echo "The daemon will be run at boot with crontab. Checking installation..." + + + if [ -f /etc/crontab ]; then + echo "Crontab is installed" + echo "Do you want to add the daemon to crontab? (y/n)" + read crontab + + if [ $crontab = "y" ]; then + + if crontab -l | grep -q "/usr/bin/librehomeworkd"; then + echo "The daemon is already in crontab" + else + echo "Adding the daemon to crontab..." + sudo crontab -l > crontab.tmp + echo "@reboot /usr/bin/librehomeworkd" >> crontab.tmp + crontab crontab.tmp + rm crontab.tmp + echo "Done, the daemon should start notifying the tasks soon. You can remove it by editing the crontab" + fi + else + echo "The daemon won't be run at boot" + fi + else + echo "Crontab is not installed, you can install it with sudo apt install cron" + fi + +else + echo "No daemon has been downloaded" +fi \ No newline at end of file diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh new file mode 100755 index 0000000000000000000000000000000000000000..52b9d8d5a8d7b9ae6ab4412963958a2183799fc1 --- /dev/null +++ b/scripts/uninstall.sh @@ -0,0 +1,56 @@ +echo "LibreHomework Uninstaller" +echo "This script will uninstall LibreHomework and remove the daemon from crontab" +echo "Do you want to continue? (y/n)" +read continue +if [ $continue = "y" ]; then + + if crontab -l | grep -q "/usr/bin/librehomeworkd"; then + echo "The daemon is in crontab, removing it..." + crontab -l > crontab.tmp + + line=$(grep -n 'librehomeworkd' crontab.tmp) + sed ${line:0:1}d cron.tmp > _crontab.tmp + + crontab -r + crontab _crontab.tmp + rm crontab.tmp + echo "Done" + else + echo "The daemon is not in crontab" + fi + + if [ -f /usr/bin/librehomeworkd ]; then + echo "Removing the daemon from /usr/bin/librehomeworkd" + sudo rm /usr/bin/librehomeworkd + echo "Done" + else + echo "The daemon is not installed" + fi + + if [ -z "$XDG_CONFIG_HOME" ]; then + XDG_CONFIG_HOME="$HOME/.config" + echo "Done" + fi + + if [ -d "$XDG_CONFIG_HOME/LibreHomework" ]; then + echo "Removing the configuration directory" + rm -rf "$XDG_CONFIG_HOME/LibreHomework" + echo "Done" + + else + echo "The configuration files are not installed" + fi + + #check if /usr/bin/libre-homework exists + if [ -f /usr/bin/libre-homework ]; then + echo "Removing the app /usr/bin/libre-homework with apt, please enter the password:" + sudo apt remove libre-homework -y + echo "Done" + else + echo "The app is not installed" + fi + + echo "LibreHomework has been completely uninstalled" +else + echo "Aborting" +fi \ No newline at end of file