Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7edaa9c289
Fetching contributors…

Cannot retrieve contributors at this time

executable file 197 lines (155 sloc) 4.323 kb
#!/usr/bin/env bash
log() { printf "$*\n" ; return $? ; }
fail() { log "ERROR: $*" ; exit 1 ; }
setup_redis_user()
{
if [[ $UID -eq 0 ]] ; then
(
case "$(uname)" 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 /sbin/nologin -d /var/lib/redis "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 /sbin/nologin -d /var/lib/redis "redis_user"
;;
"SunOS")
groupadd "$redis_user"
useradd -g "$redis_user" -s /sbin/nologin -d /var/lib/redis "redis_user"
;;
esac
) || true # Ignore failures with this for now...
fi
return 0
}
create_redis_directories()
{
local directory redis_path
log "#creating paths for ${package} ${version}...\n"
# TODO: can likely merge directory creation into path creation.
for directory in "${directories[@]}" ; do
[[ ! -d "$directory" ]] && mkdir -p "$directory"
chown -R $user "$directory"
done
for redis_path in "${redis_paths[@]}" ; do
[[ ! -d "$redis_path" ]] && mkdir -p "$redis_path"
done
return 0
}
install_init_script()
{
log "#installing init script"
cp -f "$extension_templates_path/redis.init.template" \
"${init_scripts_path}/redis"
[[ -s "${init_scripts_path}/redis" && ! -x "${init_scripts_path}/redis" ]] &&
chmod +x "${init_scripts_path}/redis"
return 0
}
install_redis_conf()
{
if [[ -s "${redis_config_file}" ]] ; then
log "${redis_config_file} already exists, not overwriting."
else
log "#installing redis.conf file to ${redis_config_file}"
cp -f "$redis_src_path/redis.conf" "${redis_config_file}"
fi
return 0
}
cleanup()
{
log "#cleaning install files for ${package} ${version}...\n"
if ! cd "$src_path" ; then
fail "Failed changing into the $src_path source path."
fi
for entity in $(find "$src_path/" -mindepth 1 -maxdepth 1 -iname "${package}-${version}*") ; do
rm -rf "$entity"
done
return 0
}
download_redis()
{
[[ ! -d "$src_path" ]] && mkdir -p $src_path
if ! cd $src_path ; then
fail " Failed changing to $src_path"
fi
log "#downloading ${package_file}...\n"
if ! curl -O -L "${redis_url}" ; then
fail "${package_file} failed to download from '${redis_url}'."
fi
return $?
}
extract_redis()
{
if ! cd "$src_path" ; then
fail "Failed changeing to $src_path"
fi
log "#extracting ${package} ${version}...\n"
if ! tar zxf "${package_file}" ; then
fail "${package_file} failed to extract."
fi
return 0
}
build_redis()
{
if ! cd "${redis_src_path}" ; then
fail "Failed changing to ${redis_src_path} directory."
fi
# Nothing to configure, proceeding straight to make.
log "#compiling ${package} ${version}...\n"
if ! make 2>&1 > "${redis_src_path}/make.log" ; then
fail "Compiling ${package}-${version} failed, see ${redis_src_path}/make.log"
fi
return $?
}
install_redis()
{
log "#installing ${package} ${version}...\n"
for file in redis-server redis-cli ; do
if ! install -b -d -S "${redis_src_path}/${file}" "${redis_bin_path}/${file}" ; then
fail "${package} ${version} failed to install (specifically ${file}).\n"
fi
done
return 0
}
source "${extension_scripts_path}/initialize"
while [[ $# -gt 0 ]] ; do
token="$1" ; shift
case "$token" in
--trace) set -o xtrace ;;
*) fail "Unknown command line argument '$token' " ;;
esac
done
download_redis
extract_redis
build_redis
install_redis
setup_redis_user
create_redis_directories
install_init_script
install_redis_conf
log "Installation Complete."
exit 0
Jump to Line
Something went wrong with that request. Please try again.