#!/bin/bash ACTION="$1" TEAMS_SOURCES_LIST="/etc/apt/sources.list.d/teams.list" shift PACKAGE_LIST=$@ case $ACTION in getStatus) for ix in $PACKAGE_LIST do TEST=$(snap list | grep $ix | cut -d " " -f 1) if [ "$TEST" == $ix ];then echo 0 else echo 1 fi done ;; download) echo "Nothing to do" ;; preInstall) package="teams" echo "Checking if teams deb is installed..." TEST=$( dpkg-query -s $package 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" == 'installed' ];then echo "Removing Teams deb file..." apt-get remove -y $package TEST=$( dpkg-query -s $package 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" == 'installed' ];then exit 1 fi fi echo "Checking if teams sources list exits..." if [ -f $TEAMS_SOURCES_LIST ];then echo "Removing Teams sources list..." rm -f $TEAMS_SOURCES_LIST fi ;; installPackage) echo "Installing snap teams..." for ix in $PACKAGE_LIST do TEST=$(snap list | grep $ix | cut -d " " -f 1) if [ "$TEST" == "$ix" ];then snap refresh $ix else snap install $ix fi TEST=$(snap list | grep $ix | cut -d " " -f 1) if ! [ "$TEST" == $ix ];then exit 1 fi done ;; remove) for ix in $PACKAGE_LIST do snap remove $ix TEST=$(snap list | grep $ix | cut -d " " -f 1) if [ "$TEST" == $ix ];then exit 1 fi done ;; esac exit 0