-[ "$command" == "cleanup" ] && {
- echo
- echo "The following command will"
- echo "- Delete all docker images for old containers"
- echo "- Delete all stopped and orphan containers"
- echo
- read -p "Are you sure (Y/n): " -n 1 -r && echo
- if [[ $REPLY =~ ^[Yy]$ || ! $REPLY ]]
- then
- space=$(df /var/lib/docker | awk '{ print $4 }' | grep -v Available)
- echo "Starting Cleanup (bytes free $space)"
+ input=STDIN.readlines.join
+ ports = []
+ input.split('_FILE_SEPERATOR_').each do |yml|
+ yml.strip!
+ begin
+ ports += (YAML.load(yml)['expose'] || [])
+ rescue Psych::SyntaxError => e
+ puts e
+ puts "*ERROR."
+ rescue => e
+ puts yml
+ p e
+ end
+ end
+ puts ports.map { |p| p.to_s.include?(':') ? "-p\n#{p}" : "--expose\n#{p}" }.join("\n")
+RUBY