Skip to content

Instantly share code, notes, and snippets.

@happypeter
Last active July 3, 2020 07:54
Show Gist options
  • Save happypeter/4248241 to your computer and use it in GitHub Desktop.
Save happypeter/4248241 to your computer and use it in GitHub Desktop.
upload my assets to the server
#!/usr/bin/env bash
sync_dryrun()
{
echo
echo -e "\033[1m ...dryrun...\033[0m"
rsync -av --delete ~/happycasts/episodes/ peter@linode:~/media/assets/episodes/ --dry-run
echo -e "\033[1m ...dryrun...\033[0m"
echo
}
sync_dryrun
sync_server()
{
echo
echo -e "\033[1m ...syncing...\033[0m"
rsync -av --progress --delete ~/happycasts/episodes/ peter@linode:~/media/assets/episodes/
echo -e "\033[1m ...done...\033[0m"
echo
}
echo -n "Want to sync? (Y/n): "
read AAA
if [ "${AAA:-y}" = "y" ];then
sync_server
else
echo Nothing done, bye.
fi
@LinuxGit
Copy link

@happypeter,Could you tell me the meaning of ${AAA:-y}? "$AAA" = "y" also does work when I test.

@happypeter
Copy link
Author

${AAA:-y} 这样 AAA 会有一个默认值 y 。 好处是如果我直接敲回车,那么 sync_server 是会执行的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment