install.sh: add --nonroot mode
This implements the way to install Scylla without requires root privilege, not distribution dependent, does not uses package manager.
This commit is contained in:
parent
e8355087ea
commit
9ef12f4651
66
install.sh
66
install.sh
@ -29,6 +29,7 @@ Usage: install.sh [options]
|
|||||||
Options:
|
Options:
|
||||||
--root /path/to/root alternative install root (default /)
|
--root /path/to/root alternative install root (default /)
|
||||||
--prefix /prefix directory prefix (default /usr)
|
--prefix /prefix directory prefix (default /usr)
|
||||||
|
--nonroot shortcut of '--disttype nonroot'
|
||||||
--sysconfdir /etc/sysconfig specify sysconfig directory name
|
--sysconfdir /etc/sysconfig specify sysconfig directory name
|
||||||
--help this helpful message
|
--help this helpful message
|
||||||
EOF
|
EOF
|
||||||
@ -36,8 +37,8 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
root=/
|
root=/
|
||||||
prefix=/opt/scylladb
|
|
||||||
sysconfdir=/etc/sysconfig
|
sysconfdir=/etc/sysconfig
|
||||||
|
nonroot=false
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -49,6 +50,10 @@ while [ $# -gt 0 ]; do
|
|||||||
prefix="$2"
|
prefix="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
"--nonroot")
|
||||||
|
nonroot=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
"--sysconfdir")
|
"--sysconfdir")
|
||||||
sysconfdir="$2"
|
sysconfdir="$2"
|
||||||
shift 2
|
shift 2
|
||||||
@ -63,24 +68,57 @@ while [ $# -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
rprefix="$root/$prefix"
|
if [ -z "$prefix" ]; then
|
||||||
retc="$root/etc"
|
if $nonroot; then
|
||||||
rusr="$root/usr"
|
prefix=~/scylladb
|
||||||
rsysconfdir="$root/$sysconfdir"
|
else
|
||||||
|
prefix=/opt/scylladb
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
rprefix=$(realpath -m "$root/$prefix")
|
||||||
|
if ! $nonroot; then
|
||||||
|
retc="$root/etc"
|
||||||
|
rsysconfdir="$root/$sysconfdir"
|
||||||
|
rusr="$root/usr"
|
||||||
|
rsystemd="$rusr/lib/systemd/system"
|
||||||
|
else
|
||||||
|
retc="$rprefix/etc"
|
||||||
|
rsysconfdir="$rprefix/$sysconfdir"
|
||||||
|
rsystemd="$retc/systemd"
|
||||||
|
fi
|
||||||
|
|
||||||
install -d -m755 "$rsysconfdir"
|
install -d -m755 "$rsysconfdir"
|
||||||
install -d -m755 "$rusr"/lib/systemd/system
|
install -d -m755 "$rsystemd"
|
||||||
install -d -m755 "$rprefix/scripts" "$rprefix/jmx" "$rprefix/jmx/symlinks"
|
install -d -m755 "$rprefix/scripts" "$rprefix/jmx" "$rprefix/jmx/symlinks"
|
||||||
|
|
||||||
install -m644 dist/common/sysconfig/scylla-jmx -Dt "$rsysconfdir"
|
install -m644 dist/common/sysconfig/scylla-jmx -Dt "$rsysconfdir"
|
||||||
install -m644 dist/common/systemd/scylla-jmx.service -Dt "$rusr"/lib/systemd/system
|
install -m644 dist/common/systemd/scylla-jmx.service -Dt "$rsystemd"
|
||||||
if [ "$sysconfdir" != "/etc/sysconfig" ]; then
|
if ! $nonroot; then
|
||||||
install -d -m755 "$retc"/systemd/system/scylla-jmx.service.d
|
if [ "$sysconfdir" != "/etc/sysconfig" ]; then
|
||||||
cat << EOS > "$retc"/systemd/system/scylla-jmx.service.d/sysconfdir.conf
|
install -d -m755 "$retc"/systemd/system/scylla-jmx.service.d
|
||||||
|
cat << EOS > "$retc"/systemd/system/scylla-jmx.service.d/sysconfdir.conf
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=
|
EnvironmentFile=
|
||||||
EnvironmentFile=$sysconfdir/scylla-jmx
|
EnvironmentFile=$sysconfdir/scylla-jmx
|
||||||
EOS
|
EOS
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install -d -m755 "$retc"/systemd/system/scylla-jmx.service.d
|
||||||
|
cat << EOS > "$retc"/systemd/system/scylla-jmx.service.d/nonroot.conf
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=
|
||||||
|
EnvironmentFile=$retc/sysconfig/scylla-jmx
|
||||||
|
ExecStart=
|
||||||
|
ExecStart=$rprefix/jmx/scylla-jmx \$SCYLLA_JMX_PORT \$SCYLLA_API_PORT \$SCYLLA_API_ADDR \$SCYLLA_JMX_ADDR \$SCYLLA_JMX_FILE \$SCYLLA_JMX_LOCAL \$SCYLLA_JMX_REMOTE \$SCYLLA_JMX_DEBUG
|
||||||
|
User=
|
||||||
|
Group=
|
||||||
|
EOS
|
||||||
|
if [ ! -d ~/.config/systemd/user/scylla-jmx.service.d ]; then
|
||||||
|
mkdir -p ~/.config/systemd/user/scylla-jmx.service.d
|
||||||
|
fi
|
||||||
|
ln -srf $rsystemd/scylla-jmx.service ~/.config/systemd/user/
|
||||||
|
ln -srf "$retc"/systemd/system/scylla-jmx.service.d/nonroot.conf ~/.config/systemd/user/scylla-jmx.service.d
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install -m644 scylla-jmx-1.0.jar "$rprefix/jmx"
|
install -m644 scylla-jmx-1.0.jar "$rprefix/jmx"
|
||||||
@ -88,3 +126,11 @@ install -m755 scylla-jmx "$rprefix/jmx"
|
|||||||
ln -sf /usr/bin/java "$rprefix/jmx/symlinks/scylla-jmx"
|
ln -sf /usr/bin/java "$rprefix/jmx/symlinks/scylla-jmx"
|
||||||
# create symlink for /usr/lib/scylla/jmx
|
# create symlink for /usr/lib/scylla/jmx
|
||||||
ln -srf $rprefix/jmx "$rprefix/scripts/"
|
ln -srf $rprefix/jmx "$rprefix/scripts/"
|
||||||
|
|
||||||
|
if $nonroot; then
|
||||||
|
sed -i -e "s#/var/lib/scylla#$rprefix#g" "$rsysconfdir"/scylla-jmx
|
||||||
|
sed -i -e "s#/etc/scylla#$rprefix/etc/scylla#g" "$rsysconfdir"/scylla-jmx
|
||||||
|
sed -i -e "s#/opt/scylladb/jmx#$rprefix/jmx#g" "$rsysconfdir"/scylla-jmx
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
echo "Scylla-JMX non-root install completed."
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user