echo "immudex-upgrade - script for searching upgrades and upgrade immudex";
echo "@ 2023 morketsmerke.org";
echo "Options:";
- echo " --check --print - check there are upgrades for immudex";
- echo " --upgrade - check there are upgrades for immudex and install them.";
- echo " If there is no new version, script will propose refreshing";
- echo " current immudex installation, its helpful when you tried";
- echo " remaster immudex and you get any trouble with this".
- echo " --version - getting latest version of immudex";
- echo " --branch <stable/testing> - change immudex branch";
- echo " Switch between stable or testing version and vice versa"
+ echo " --check - check there are upgrades for immudex";
+ echo " --upgrade - upgrade immudex from given source";
}
function main_upgrade() {
sudo cp /tmp/version ${1}/live;
}
-function check_mirror() {
- mirrorList=("sourceforge.net=https://sourceforge.net/projects/immudex/files", "plikownia.zsgronowo.edu.pl=https://plikownia.zsgronowo.edu.pl/pliki/Nauczyciele/Administrator/files", "ftp.morketsmerke.org=https://ftp.morketsmerke.org");
- for i in ${mirrorList[@]}; do
- name=$(echo $i | cut -d "=" -f 1);
- address=$(echo $i | cut -d "=" -f 2 | sed 's/,//');
- echo -en "Checking is ${YELLOW}${name}${ENDCOLOR} available..." 1>&2;
- curl ${address}/immudex/stable/upgrades/latest/64/version > /dev/null 2>&1;
- if [ $? -eq 0 ]; then
- echo -e "[ ${GREEN}OK${ENDCOLOR} ]" 1>&2;
- mirror=$address;
- mirror_name=$name;
+if [ "$1" ]; then
+ if [ "$1" ] && [ "$1" = "--check" ]; then
+ if check_distro_commit; then
+ echo -e "${GREEN}This${ENDCOLOR} is the latest version of immudex";
else
- echo -e "[ ${RED}FAIL${ENDCOLOR} ]" 1>&2;
- fi
- done
- if [ "$mirror" ]; then
- echo "Choosing $mirror_name" 1>&2;
- echo $mirror;
- else exit 1; fi
-}
-
-if [ "$1" ] && [ "$1" = "--check" ]; then
- if [ "$2" ] && [ "$2" = "--print" ]; then
- newVersion=$(check_distro_version --print);
- if check_distro_version; then
- echo -e "${YELLOW}New version (${ENDCOLOR}${RED}$newVersion${ENDCOLOR}${YELLOW}) of immudex is available to upgrade.${ENDCOLOR}";
- else
- echo -e "${YELLOW}This (${ENDCOLOR}${GREEN}$newVersion${ENDCOLOR}${YELLOW}) is the latest version of immudex.${ENDCOLOR}";
- fi
- elif [ "$2" = "--mirror" ]; then
- mirror=$(check_mirror);
- echo $mirror;
- fi
-elif [ "$1" ] && [ "$1" = "--upgrade" ]; then
- newVersionTxt=$(check_distro_version --print);
- newVersionInt=$(echo $newVersionTxt | sed 's/\.//g');
- if check_distro_version; then
- echo -en "${YELLOW}New version "
- echo -en "(${ENDCOLOR}${RED}${newVersionTxt}${ENDCOLOR}${YELLOW}) "
- echo -e "of immudex is available.${ENDCOLOR}";
- echo -e "${RED}Warning, reboot maybe necessary to continue work on this machine${ENDCOLOR}";
- echo -en "${YELLOW}Do you want upgrade this system? (y/n):${ENDCOLOR} ";
- read commit;
- if [ $commit = "y" ]; then
- echo "Upgrading immudex to the newest version...";
- main_upgrade $root $newVersionTxt;
- if [ $? -eq 0 ]; then echo -e "Upgrading immudex to the newest version...[ ${GREEN}OK${ENDCOLOR} ]"; fi
- else
- exit 1;
- fi
- else
- echo -e "${GREEN}There is no newer version of immudex,${ENDCOLOR}";
- echo -e "${YELLOW}but you can copy fresh system files from latest iso image";
- echo -e "${RED}Warning, reboot maybe necessary to continue work on this machine${ENDCOLOR}";
- echo -en "${YELLOW}Do you want refresh this system? (y/n):${ENDCOLOR} ";
- read commit;
- if [ $commit = "y" ]; then
- echo "Refreshing immudex to the latest iso image...";
- main_upgrade $root $newVersionTxt;
- if [ $? -eq 0 ]; then echo -e "Refreshing immudex to the latest iso image...[ ${GREEN}OK${ENDCOLOR} ]"; fi
- else
- exit 1;
- fi
- exit 0;
- fi
-elif [ "$1" ] && [ "$1" = "--version" ]; then
- MIRROR=$(check_mirror);
- stable64=$(curl ${MIRROR}/immudex/stable/upgrades/latest/64/version 2>/dev/null)
- stable32=$(curl ${MIRROR}/immudex/stable/upgrades/latest/32/version 2>/dev/null)
- testing64=$(curl ${MIRROR}/immudex/testing/upgrades/latest/64/version 2>/dev/null)
- testing32=$(curl ${MIRROR}/immudex/testing/upgrades/latest/32/version 2>/dev/null)
- branch=$(get_debian_branch);
- localVer=$(cat /run/live/medium/live/version);
- if [ "$(uname -m)" = "x86_64" ]; then
- arch="amd64";
- stable=$stable64;
- testing=$testing64;
- else
- arch="i386";
- stable=$stable32;
- testing=$testing32;
- fi
- echo "Arch: $arch";
- echo "Local: ${localVer} (${branch})";
- echo "Stable: $stable";
- echo "Testing: $testing";
-elif [ "$1" ] && [ "$1" = "--branch" ]; then
- if [ "$2" ] && ([ "$2" = "stable" ] || [ "$2" = "testing" ]); then
- BRANCH=$2;
- ARCH=$(get_machine_arch);
- export $BRANCH;
- echo -en "${YELLOW}Do you really want change immudex branch (y/n):${ENDCOLOR} ";
- read commit;
- if [ $commit = "y" ]; then
- echo "Changing immudex branch to ${BRANCH}...";
- newVersionTxt=$(curl https://ftp.morketsmerke.org/immudex/${BRANCH}/upgrades/latest/${ARCH}/version 2>/dev/null);
- main_upgrade $root $newVersionTxt;
- if [ $? -eq 0 ]; then echo -e "Changing immudex branch to ${BRANCH}...[ ${GREEN}OK${ENDCOLOR} ]"; fi
- else
- exit 1;
+ echo -e "There is a ${RED}new${ENDCOLOR} version of immudex";
+ check_distro_commit --print;
fi
+ elif [ "$1" ] && [ "$1" = "--upgrade" ]; then
+
else
- help; exit 1;
- fi
+ help;
+ exit 1;
else
help;
exit 1;