sync-sourceforge-pages.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #! /usr/bin/env bash
  2. set -e
  3. user_name=milahu
  4. repo_name=alchi-journal
  5. # chdir to repo root
  6. cd "$(dirname "$0")"/..
  7. repo_root="$(pwd)"
  8. tempdir=$(mktemp -d)
  9. echo "using tempdir $tempdir"
  10. cd $tempdir
  11. echo "cloning from '$repo_root' to '$tempdir/$repo_name'"
  12. git clone --depth=1 "file://$repo_root" $repo_name
  13. cd $repo_name
  14. ls -A
  15. git log | head
  16. git status
  17. echo pushing files to sourceforge.net
  18. # https://sourceforge.net/p/forge/documentation/rsync/#project-web-use
  19. # rsync --delete: delete extraneous files from dest dirs
  20. # rsync --cvs-exclude: ignore .git/
  21. # rsync --links: copy symlinks as symlinks
  22. # https://sourceforge.net/p/forge/documentation/SSH%20Key%20Fingerprints/
  23. # web.sourceforge.net, web.sf.net, frs.sourceforge.net, frs.sf.net
  24. # SHA256:209BDmH3jsRyO9UeGPPgLWPSegKmYCBIya0nR/AWWCY
  25. known_hosts_line='web.sourceforge.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQD35Ujalhh+JJkPvMckDlhu4dS7WH6NsOJ15iGCJLC'
  26. if ! grep -q -x "$known_hosts_line" $HOME/.ssh/known_hosts; then
  27. echo "$known_hosts_line" >>$HOME/.ssh/known_hosts
  28. fi
  29. # https://stackoverflow.com/questions/3299951/how-to-pass-password-automatically-for-rsync-ssh-command
  30. password_file="$repo_root/secrets/password-web.sourceforge.net.txt"
  31. # no. The --password-file option may only be used when accessing an rsync daemon.
  32. # rsync --password-file="$password_file"
  33. if ! [ -e "$password_file" ]; then
  34. echo "error: missing password file: $password_file"
  35. exit 1
  36. fi
  37. # rsync --rsh=ssh: interactive login
  38. ssh_username=$user_name
  39. ssh_password=$(cat "$password_file")
  40. rsync --recursive --compress --delete --cvs-exclude --links \
  41. --rsh="sshpass -p $ssh_password ssh -o StrictHostKeyChecking=no -l $ssh_username" \
  42. ./ $user_name@web.sourceforge.net:/home/project-web/$user_name-$repo_name/htdocs/
  43. echo removing tempdir $tempdir
  44. rm -rf $tempdir