cat $HOME/idle/idle_preseed.yaml | sudo lxd init --preseed;
}
+
+function idle-get-container-name-list() {
+ rpmGrepOpts='-E rocky.sh|fedora.sh|opensuse.sh';
+ debGrepOpts='deb.sh';
+ otherGrepOpts='-v -E rocky.sh|fedora.sh|opensuse.sh|deb.sh';
+ if [ "$1" = "--deb" ]; then
+ echo $(grep $debGrepOpts $DATABASE | cut -d ";" -f 3 | awk '{printf $1" "}');
+ elif [ "$1" = "--rpm" ]; then
+ echo $(grep $rpmGrepOpts $DATABASE | cut -d ";" -f 3 | awk '{printf $1" "}');
+ elif [ "$1" = "--other" ]; then
+ echo $(grep $otherGrepOpts $DATABASE | cut -d ";" -f 3 | awk '{printf $1" "}');
+ elif [ "$1" = "--all" ]; then
+ echo $(cut -d ";" -f 3 $DATABASE | awk '{printf $1" "}');
+ elif echo $1 | grep -q '\,'; then
+ echo $(echo $1 | sed 's/,/ /g');
+ fi
+}
+
function idle-list-containers() {
if ! lxc profile show default | grep -q 'idle'; then
echo -e "${RED}LXD isn't initialized. You must run 'idle-lxd-init' firs${ENDCOLOR}";
exit 1;
else
- for container in $(cut -d ";" -f 3 $DATABASE | awk '{printf $1" "}'); do
+ containerNameList=$(idle-get-container-name-list --all);
+ for container in $containerNameList; do
if lxc info $container >> /dev/null 2>&1; then
installed="\e[32m\u2714\e[0m";
else
}
function list-containers() {
- containerNameList=$(grep $@ $DATABASE | cut -d ";" -f 3 | awk '{printf $1" "}');
+ containerNameList=$(idle-get-container-name-list $1);
for contName in $containerNameList; do
echo -e " $contName";
done
}
+
+
function mass-create-container() {
- if echo $1 | grep -q '\,'; then
- containerNameList=$(echo $1 | sed 's/,/ /g');
- else
- containerNameList=$(grep $@ $DATABASE | cut -d ";" -f 3 | awk '{printf $1" "}');
- fi
+ containerNameList=$(idle-get-container-name-list $1);
for contName in $containerNameList; do
create-container $contName;
done
exit 1;
else
if [ "$1" ]; then
- if [ "$1" = "--all" ]; then
- containerNameList=$(cut -d ";" -f 3 $DATABASE | awk '{printf $1" "}');
- for contName in $containerNameList; do
- create-container $contName;
- done
- elif [ "$1" = "--deb" ]; then
- mass-create-container $debGrepOpts;
- elif [ "$1" = "--rpm" ]; then
- mass-create-container $rpmGrepOpts;
- elif [ "$1" = "--other" ]; then
- mass-create-container $otherGrepOpts;
- elif echo $1 | grep -q '\,'; then
+ if echo $1 | grep -q '\-\-'; then
mass-create-container $1;
else
contName=$1;
containerName=$1;
lxc delete -f $containerName;
}
+
+