You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.3 KiB

  1. #!/bin/sh -e
  2. #
  3. # rc.local
  4. #
  5. # This script is executed at the end of each multiuser runlevel.
  6. # Make sure that the script will "exit 0" on success or any other
  7. # value on error.
  8. #
  9. # In order to enable or disable this script just change the execution
  10. # bits.
  11. #
  12. # By default this script does nothing.
  13. create_user_dir() {
  14. local u="$1" d=
  15. shift
  16. for d; do
  17. if [ ! -d "$d" ]; then
  18. mkdir "$d"
  19. chown "$u:$u" "$d"
  20. fi
  21. done
  22. }
  23. create() {
  24. local u="$1" d0="$2" d1="$3" dp=
  25. create_user_dir "$u" "$d1"
  26. if [ "$(readlink "$d0")" != "$d1" ]; then
  27. create_user_dir "$u" "$(dirname "$d0")"
  28. rm -rf "$d0"
  29. ln -snf "$d1" "$d0"
  30. fi
  31. }
  32. mount2() {
  33. local d="$1"
  34. shift
  35. if ! grep -q " $d " /proc/mounts; then
  36. mount "$@" "$d"
  37. fi
  38. }
  39. T=/var/cache/tmpfs
  40. mkdir -p "$T"
  41. mount2 "$T" -t tmpfs -o nosuid,nodev none
  42. #mount2 /var/cache/apt -t tmpfs -o nosuid,nodev none
  43. for user in ame amery xubuntu; do
  44. [ -d "/home/$user" ] || continue
  45. create_user_dir "$user" "/var/cache/tmpfs/$user"
  46. for d in \
  47. .cache \
  48. .cache/mozilla \
  49. ; do
  50. create_user_dir "$user" "/home/$user/$d" "/var/cache/tmpfs/$user/$d"
  51. done
  52. for d in \
  53. .cache/thunderbird \
  54. .cache/chromium \
  55. .cache/google-chrome \
  56. .cache/mozilla/firefox \
  57. ; do
  58. create "$user" "/home/$user/$d" "/var/cache/tmpfs/$user/$d"
  59. done
  60. done
  61. exit 0