install_syncthing.ksh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/ksh
  2. doas pkg_add syncthing
  3. syncthing_xsession="$(cat ~/.xsession | grep "syncthing --no-browser &")"
  4. if [ "$syncthing_xsession" = "" ]; then
  5. print "INFO: Adding syncthing to ~/.xsession..."
  6. {
  7. echo ""
  8. echo '# start syncthing'
  9. echo 'syncthing --no-browser &'
  10. } >>$HOME/.xsession
  11. fi
  12. kern_maxfiles="$(cat /etc/sysctl.conf | grep "kern.maxfiles=80000")"
  13. if [ "$kern_maxfiles" = "" ]; then
  14. doas sed 's/kern.maxfiles=.*/kern.maxfiles=80000/' /etc/sysctl.conf
  15. doas sysctl kern.maxfiles=80000
  16. fi
  17. doas cp /etc/login.conf /etc/login.conf.bak
  18. doas sed -ie 's/:openfiles-max=1024:/:openfiles-max=16000:/g' /etc/login.conf
  19. doas sed -ie 's/:openfiles-cur=512:/:openfiles-cur=8000:/g' /etc/login.conf
  20. syncthing_loginconf="$(cat /etc/login.conf | grep "syncthing:")"
  21. if [ "$syncthing_loginconf" = "" ]; then
  22. print "INFO: Adding syncthing to /etc/login.conf..."
  23. {
  24. echo ''
  25. echo 'syncthing:\'
  26. echo ' :openfiles-cur=8000:\'
  27. echo ' :openfiles-max=16000:\'
  28. echo ' :tc=daemon:'
  29. } | doas tee -a /etc/login.conf
  30. doas cap_mkdb /etc/login.conf
  31. fi
  32. echo ""
  33. echo " NOTE: On OpenBSD is better to disable 'watch for changes' and then set 'full rescan interval = 60'"
  34. echo " in the 'advanced' tab in a folder's settings (on the web UI)."
  35. echo ""
  36. echo " This is to avoid the warning: "
  37. echo " Filesystem watching (kqueue) is enabled on 'Folder' (XXXX) with a lot of files/directories"