avalonhost-raminst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. # Copyright 2013 Luke Dashjr
  3. #
  4. # This program is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU General Public License as published by the Free Software
  6. # Foundation; either version 3 of the License, or (at your option) any later
  7. # version. See COPYING for more details.
  8. set -e
  9. if test "$#" -lt 2; then
  10. echo "Usage: $0 <bfgminer-version> <temporary-packages...>"
  11. echo "Example: $0 testing bfgminer screen"
  12. echo "Installs <temporary-packages> to RAM, on an Avalon-host router"
  13. echo "Version can be 'stable', 'testing', or any 3-digit version; eg '3.1.0'"
  14. echo "Do NOT attempt to reverse (uninstall) except by rebooting"
  15. echo "Do NOT attempt to use this script more than once per boot"
  16. exit 1
  17. fi
  18. die() {
  19. echo "$@"
  20. echo 'ABORTING'
  21. exit 1
  22. }
  23. if ! grep TL-WR703N /proc/cpuinfo; then
  24. die 'This doesn'\''t seem to be an Avalon host system'
  25. fi
  26. if test "$USER" != "root"; then
  27. die "Must be run as root"
  28. fi
  29. echo "WARNING: If anything fails other than opkg and crontab, reboot ASAP"
  30. source /lib/functions.sh
  31. mkdir -p /tmp/root/.oldroot
  32. mount -o noatime,lowerdir=/rom,upperdir=/tmp/root -t overlayfs "overlayfs:/tmp/root" /mnt
  33. pivot /mnt /.oldroot
  34. mount -o noatime,move /.oldroot/rom /rom
  35. sed -i 's/\(^option[[:space:]]\+overlay_root[[:space:]]\+\).*//;T;d' /etc/opkg.conf
  36. {
  37. echo 'option overlay_root /'
  38. echo "src/gz bfgminer http://luke.dashjr.org/programs/bitcoin/files/bfgminer/$1/openwrt/12.09/ar71xx"
  39. } >> /etc/opkg.conf
  40. shift
  41. set +e
  42. opkg update
  43. opkg install "$@"
  44. crontab -r # disabled cgminer-monitor
  45. set -e
  46. mount -o noatime,lowerdir=/,upperdir=/overlay -t overlayfs "overlayfs:/overlay" /mnt
  47. pivot /mnt /.oldroot
  48. mount -o noatime,move /.oldroot/rom /rom