create repo
This commit is contained in:
82
amisearch
Executable file
82
amisearch
Executable file
@@ -0,0 +1,82 @@
|
||||
#!/bin/sh
|
||||
|
||||
ESC=`printf "\033"`;
|
||||
REGION=$1;
|
||||
|
||||
input_key() {
|
||||
read -s -n3 INPUT;
|
||||
echo $INPUT;
|
||||
}
|
||||
|
||||
check_selected() {
|
||||
if [ $1 = $2 ];
|
||||
then echo " => "
|
||||
else echo " "
|
||||
fi
|
||||
}
|
||||
|
||||
select_menu() {
|
||||
SELECTED=1;
|
||||
INPUT="";
|
||||
MIN_MENU=1;
|
||||
MAX_MENU=$#;
|
||||
while true;
|
||||
do
|
||||
for (( i=1; i<=$#; i++))
|
||||
do
|
||||
printf "$ESC[2K$(check_selected $i $SELECTED) $i. ${!i}\n";
|
||||
done
|
||||
printf "\n$ESC[2KMake AMI!\n\n";
|
||||
INPUT=$(input_key);
|
||||
if [[ $INPUT = "" ]];
|
||||
then break;
|
||||
fi
|
||||
|
||||
if [[ $INPUT = $ESC[A ]];
|
||||
then SELECTED=$(expr $SELECTED - 1);
|
||||
elif [[ $INPUT = $ESC[B ]];
|
||||
then SELECTED=$(expr $SELECTED + 1);
|
||||
fi
|
||||
|
||||
if [[ $SELECTED -lt $MIN_MENU ]];
|
||||
then SELECTED=${MIN_MENU};
|
||||
elif [[ $SELECTED -gt $MAX_MENU ]];
|
||||
then SELECTED=${MAX_MENU};
|
||||
fi
|
||||
|
||||
printf "$ESC[$(expr $# + 3)A";
|
||||
done
|
||||
return `expr ${SELECTED} - 1`;
|
||||
}
|
||||
|
||||
select_test() {
|
||||
if [ -z $REGION ]
|
||||
then
|
||||
echo "./amisearch region"
|
||||
exit
|
||||
fi
|
||||
arr_params=("amazon" "centos" "ubuntu" "redhat");
|
||||
echo "\nWelmcome! AWS AMI Selector\n";
|
||||
select_menu "${arr_params[@]}";
|
||||
local SELECTED=$?;
|
||||
SELECTED_MODE=${arr_params[${SELECTED}]};
|
||||
}
|
||||
|
||||
main() {
|
||||
select_test;
|
||||
if [ $SELECTED -eq 1 ]
|
||||
then
|
||||
aws ec2 describe-images --owners 137112412989 --query 'sort_by(Images, &CreationDate)[*].[CreationDate,Name,ImageId]' --filters "Name=name,Values=amzn2*" --region $REGION --output table
|
||||
elif [ $SELECTED -eq 2 ]
|
||||
then
|
||||
aws ec2 describe-images --owners 125523088429 --query 'sort_by(Images, &CreationDate)[*].[CreationDate,Name,ImageId]' --filters "Name=name,Values=Cent*" --region $REGION --output table
|
||||
elif [ $SELECTED -eq 3 ]
|
||||
then
|
||||
aws ec2 describe-images --owners 099720109477 --query 'sort_by(Images, &CreationDate)[*].[CreationDate,Name,ImageId]' --filters "Name=name,Values=ubuntu-minimal/images/hvm-ssd*" --region $REGION --output table
|
||||
elif [ $SELECTED -eq 4 ]
|
||||
then
|
||||
aws ec2 describe-images --owners 309956199498 --query 'sort_by(Images, &CreationDate)[*].[CreationDate,Name,ImageId]' --filters "Name=name,Values=RHEL-8*" --region $REGION --output table
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user