#!/bin/bash
set -e

if [ -f /etc/os-release ]; then
    . /etc/os-release
    OS=$NAME
else
    OS="none"
fi

if [ ! -d ~/linuxbox ]; then
    cd ~ &&
        git clone https://git.cmtec.se/cm/linuxbox.git
fi

if [ -d ~/linuxbox ]; then
    cd ~/linuxbox &&
        git pull &&
        if [ "$OS" == "Ubuntu" ]; then
            ./update_ubuntu.sh
        elif [ "$OS" == "Arch Linux" ]; then
            ./update_arch.sh
        fi
fi
