install.sh: run post-install script just like .rpm/.deb package

To install scylla using install.sh easily, we need to run following things:
 - add scylla user/group
 - configure scylla.yaml
 - run scylla_post_install.sh

But we don't want to run them when we build .rpm/.deb package,
we also need to add --packaging option to skip them.

Fixes #5830
This commit is contained in:
Takuya ASADA
2020-02-22 08:09:42 +09:00
committed by Avi Kivity
parent 956b092012
commit 01a03c4d69
3 changed files with 37 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ override_dh_auto_clean:
override_dh_auto_install:
dh_auto_install
./install.sh --root "$(CURDIR)/debian/tmp" $(install_arg) --sysconfdir "/etc/default"
./install.sh --packaging --root "$(CURDIR)/debian/tmp" $(install_arg) --sysconfdir "/etc/default"
# don't use default sysconfig file, use Debian version
cp dist/debian/sysconfig/scylla-housekeeping $(CURDIR)/debian/tmp/etc/default/

View File

@@ -68,7 +68,7 @@ defines=()
{{#housekeeping}}
install_arg="--housekeeping"
{{/housekeeping}}
./install.sh --root "$RPM_BUILD_ROOT" $install_arg
./install.sh --packaging --root "$RPM_BUILD_ROOT" $install_arg
%pre server
getent group scylla || /usr/sbin/groupadd scylla 2> /dev/null || :

View File

@@ -33,6 +33,7 @@ Options:
--housekeeping enable housekeeping service
--nonroot install Scylla without required root priviledge
--sysconfdir /etc/sysconfig specify sysconfig directory name
--packaging use install.sh for packaging
--help this helpful message
EOF
exit 1
@@ -43,6 +44,7 @@ housekeeping=false
python3=/opt/scylladb/python3/bin/python3
sysconfdir=/etc/sysconfig
nonroot=false
packaging=false
while [ $# -gt 0 ]; do
case "$1" in
@@ -70,6 +72,10 @@ while [ $# -gt 0 ]; do
sysconfdir="$2"
shift 2
;;
"--packaging")
packaging=true
shift 1
;;
"--help")
shift 1
print_usage
@@ -321,4 +327,33 @@ if $nonroot; then
touch $rprefix/SCYLLA-NONROOT-FILE
systemctl --user daemon-reload
echo "Scylla non-root install completed."
elif ! $packaging; then
nousr=
nogrp=
getent passwd scylla || nousr=1
getent group scylla || nogrp=1
# this handles both case group is not exist || group already exists
if [ $nousr ]; then
adduser --system \
--quiet \
--home /var/lib/scylla \
--no-create-home \
--disabled-password \
--group scylla
# only group is not exist, create it and add user to the group
elif [ $nogrp ]; then
addgroup --system scylla
adduser scylla scylla
fi
chown -R scylla:scylla $rdata
chown -R scylla:scylla $rhkdata
grep -v api_ui_dir /etc/scylla/scylla.yaml | grep -v api_doc_dir > /tmp/scylla.yaml
echo "api_ui_dir: /opt/scylladb/swagger-ui/dist/" >> /tmp/scylla.yaml
echo "api_doc_dir: /opt/scylladb/api/api-doc/" >> /tmp/scylla.yaml
mv /tmp/scylla.yaml /etc/scylla/scylla.yaml
$rprefix/scripts/scylla_post_install.sh
fi