10-fixuser 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/with-contenv bash
  2. ## 软连接chrome
  3. if [[ -n $(ls /root/.cache/rod/browser 2>/dev/null) ]]; then
  4. target_chrome=/root/.cache/rod/browser/$(ls -t /root/.cache/rod/browser | head -1)/chrome-linux/chrome
  5. if [[ -L /usr/bin/chrome && $(readlink -f /usr/bin/chrome) != $target_chrome ]]; then
  6. rm -f /usr/bin/chrome
  7. ln -s $target_chrome /usr/bin/chrome &>/dev/null
  8. elif [[ ! -e /usr/bin/chrome ]]; then
  9. ln -s $target_chrome /usr/bin/chrome &>/dev/null
  10. fi
  11. fi
  12. ## 重设权限
  13. chown -R "${PUID}:${PGID}" /config /root
  14. if [[ ${PERMS} == true ]]; then
  15. echo "已设置 PERMS=true,重设 '/media' 目录权限为 ${PUID}:${PGID} 所有..."
  16. chown -R ${PUID}:${PGID} /media
  17. fi
  18. ## 兼容旧的缓存目录
  19. if [[ -d /app/cache ]]; then
  20. echo "检测到映射了 '/app/cache',创建软连接 '/config/cache' -> '/app/cache'"
  21. chown -R ${PUID}:${PGID} /app
  22. if [[ -L /config/cache && $(readlink -f /config/cache) != /app/cache ]]; then
  23. rm -rf /config/cache &>/dev/null
  24. fi
  25. if [[ ! -e /config/cache ]]; then
  26. s6-setuidgid ${PUID}:${PGID} ln -sf /app/cache /config/cache
  27. fi
  28. else
  29. if [[ -L /config/cache ]]; then
  30. echo "检测到 '/config/cache' 指向了不存在的目录 '/app/cache',删除之,如想保留缓存,请将旧的 'cache' 目录移动到 '/config' 路径下..."
  31. rm -rf /config/cache &>/dev/null
  32. fi
  33. fi