Permalink
Browse files

redis_user

  • Loading branch information...
1 parent 87746b8 commit 538af7d6ec9a2fdae89abd54dea569c75fa95bbe @wayneeseguin wayneeseguin committed Mar 24, 2011
Showing with 47 additions and 3 deletions.
  1. +45 −1 redis/bin/install
  2. +2 −2 redis/scripts/initialize
View
@@ -6,7 +6,51 @@ fail() { log "ERROR: $*" ; exit 1 ; }
setup_redis_user()
{
if [[ $UID -eq 0 ]] ; then
- useradd -r redis # TODO: Make this more robust...
+
+ (
+ case "$os_type" in
+ "OpenBSD")
+ groupadd "$redis_user"
+ useradd -g "$redis_user" "redis_user" -s /bin/bash
+ ;;
+ "FreeBSD")
+ pw groupadd -q "$redis_user"
+ ;;
+ "Linux")
+ if [[ -f "/etc/SuSE-release" ]] ; then
+ groupadd "$redis_user"
+ else
+ groupadd -f "$redis_user"
+ fi
+ useradd -g "$redis_user" -s /bin/bash "redis_user"
+ ;;
+
+ "Darwin")
+ gid="501" #only gids > 500 show up in user preferences
+
+ #Find an open gid
+ while true; do
+ name=$(dscl . search /groups PrimaryGroupID $gid | cut -f1 -s)
+ if [ -z "$name" ] ; then
+ break
+ fi
+ gid=$[$gid +1]
+ done
+
+ #Create the group
+ dscl . -create "/Groups/$redis_user"
+ dscl . -create "/Groups/$redis_user" gid "$gid"
+
+ # ????
+ # useradd -g "$redis_user" -s /bin/bash "redis_user"
+ ;;
+ "SunOS")
+ groupadd "$redis_user"
+ useradd -g "$redis_user" -s /bin/bash "redis_user"
+ ;;
+ esac
+ ) || true # Ignore failures with this for now...
+
fi
return 0
}
View
@@ -44,12 +44,12 @@ result=0
if [[ $UID -eq 0 ]] ; then
prefix="${prefix:-/usr/local}"
directories=(/etc/redis /var/log/redis /var/run/redis /data/redis)
- user="redis"
+ redis_user="redis"
else
prefix="${prefix:-$HOME}"
redis_install_path="$prefix"
directories=("$HOME/.redis/log" "$HOME/.redis/data" "$HOME/.redis/pids")
- user="$USER"
+ redis_user="$USER"
fi
true ${src_path:="$prefix/src"}

0 comments on commit 538af7d

Please sign in to comment.