Skip to content

Commit

Permalink
Tarball support for HTX installation on linux distros is added
Browse files Browse the repository at this point in the history
  • Loading branch information
Raja Shekhar committed Apr 26, 2017
1 parent a428d1b commit 50879ad
Show file tree
Hide file tree
Showing 4 changed files with 391 additions and 3 deletions.
38 changes: 35 additions & 3 deletions Documentation/HTX_user_manual.txt
Expand Up @@ -35,9 +35,41 @@ HTX User Manual

HTX images can be built in .rpm or .deb format depending upon the Linux
distribution. First, uninstall the existing version of HTX, if one exists,
and then install the new version.
and then install the new version.

1.3.1 Installing an HTX RPM Package
HTX can also be built and installed using tarball.

1.3.1 Installing using HTX tarball

To install HTX using tarball, do the following steps:

1. Log in as root.
2. Clone HTX project from github
git clone https://github.com/open-power/HTX.git
3. Go inside HTX directory, Build the package and generate tarball.
a. cd HTX/
b. make clean
c. make all
d. make tar
HTX tarball by name "htx_package.tar.gz" will be created in directory (HTX/)
4. Extract tarball, Proceed for installation.
a. tar --touch -xvzf htx_package.tar.gz
b. cd htx_package
5. Installing and uninstalling HTX.
a. Make sure you are inside htx_package/ directory.
b. ./installer.sh
This will install HTX in default path: /usr/lpp/htx
c. ./installer.sh -f #Force Installation
This will automatically uninstall HTX(if its already installed) and re-install freshly
d. ./installer.sh -p /home/htx #Installation in specified path
This will install HTX in the specified path which is given as argument(In this case its inside "/home/htx")
e. ./installer.sh -p /home/htx -f #Force Installation in specified path "/home/htx"
f. ./uninstaller.sh
This will uninstall HTX from the system



1.3.2 Installing an HTX RPM Package

To install an HTX RPM package, do the following steps:

Expand All @@ -57,7 +89,7 @@ HTX User Manual
3. Install the latest RPM package for your system:
rpm -ivh <rpmfilename>

1.3.2 Installing an HTX .deb Package
1.3.3 Installing an HTX .deb Package

To install an HTX .dep package, do the following steps:

Expand Down
54 changes: 54 additions & 0 deletions Makefile
Expand Up @@ -28,6 +28,7 @@ all: ${SUBDIRS}
@echo "making dir - "${SHIPTOPDIR}
${MKDIR} ${SHIPTOPDIR}
${CP} ${TARGET} ${SHIPTOPDIR}
touch /tmp/.htx_build_done

.PHONY: clean ${SUBDIRS_CLEAN} clean_local

Expand All @@ -36,6 +37,12 @@ clean: ${SUBDIRS_CLEAN} clean_local
${RM} -rf ${SHIPDIR}
@echo "Removing dir - "${EXPORT}
${RM} -rf ${EXPORT}
${RM} -rf htx_package.tar.gz
${RM} -rf htxubuntu.deb
@if [ -e /tmp/.htx_build_done ]; \
then \
${RM} /tmp/.htx_build_done ; \
fi

${SUBDIRS_CLEAN}:
@$(MAKE) -C $(@:.clean=) clean
Expand All @@ -47,3 +54,50 @@ deb:
@echo "Making HTX Debian package..."
cp -r $(PACKAGINGDIR)/ubuntu/* $(SHIPDIR)/
dpkg-deb -b $(SHIPDIR) $(TOPDIR)/htxubuntu.deb

tar:
@if [ ! -f /tmp/.htx_build_done ] ; \
then \
echo -e "HTX is not built for tar package creation, \ndo 'make all' and retry, exiting..."; \
exit 1; \
fi;

@echo "Making TAR package..."
@echo "making dir - "${SHIPTOPDIR}/htx_binaries
${MKDIR} ${SHIPTOPDIR}/htx_binaries
${CP} -r ${SHIPDIR}/usr/bin ${SHIPTOPDIR}/htx_binaries/
${CP} -r ${SHIPDIR}/usr/sbin ${SHIPTOPDIR}/htx_binaries/
echo -ne "Compiledon-" > ${SHIPTOPDIR}/etc/version
date '+%d/%m/%Y %H:%M:%S' >> ${SHIPTOPDIR}/etc/version
${RM} -rf htx_package
${MKDIR} htx_package
tar -cvzf htx_package/htx.tar.gz -C ${SHIPDIR}/usr/lpp htx > /dev/null
${CP} $(PACKAGINGDIR)/installer.sh htx_package
${CP} $(PACKAGINGDIR)/uninstaller.sh htx_package
@if [ -f /etc/redhat-release ] ; \
then \
echo "Compiledon:RedHat" > htx_package/os_build ; \
elif [ -f /etc/SuSE-release ] ; \
then \
echo "Compiledon:SUSE" > htx_package/os_build ; \
elif [ -f /etc/debian_version ] ; \
then \
echo "Compiledon:Ubuntu" > htx_package/os_build ; \
fi;
echo -e "\nBuilt-on-Distro: " >> htx_package/os_build ;
cat /etc/*-release >> htx_package/os_build ;
echo -e "\nGLIBC Version: " >> htx_package/os_build ;
ldd --version | grep ldd >> htx_package/os_build ;
echo -e "\ngcc version: " >> htx_package/os_build ;
gcc --version | grep gcc >> htx_package/os_build ;
echo -e "\nkernel version: " >> htx_package/os_build ;
uname -r >> htx_package/os_build ;
tar -cvzf htx_package.tar.gz htx_package > /dev/null
${RM} -rf ${SHIPTOPDIR}/htx_binaries/
${RM} -rf htx_package
@if [ -f ./htx_package.tar.gz ] ; \
then \
echo -e "HTX package htx_package.tar.gz is generated successfully..."; \
else \
echo -e "HTX package generation failed.. exiting..."; \
fi;
201 changes: 201 additions & 0 deletions packaging/installer.sh
@@ -0,0 +1,201 @@
#!/bin/bash

INSTALL_LOG_FILE=/var/log/htx_install_log

if [ "$(id -u)" != "0" ]; then
echo -e "\nThis script must be run as root..exiting."
exit 1;
fi

>${INSTALL_LOG_FILE}

usage()
{
echo -e "Usage: ./installer.sh\n"
echo -e "./installer.sh -p <installation_path> [-f]\n"
echo -e "\t-f Force installation"
echo -e "\n\tEg. ./installer.sh -p /home/"
echo -e "\n\tEg. ./installer.sh -p /home/ -f"
}

while getopts ":p:f" opt
do
case $opt in
p)
INSTALL_PATH=$OPTARG;
FORCE=0;
LOCATION=1;
;;
f)
FORCE=1;
;;
\?)
echo -e "Invalid option: -$OPTARG"
usage
exit 1;
;;
:)
echo -e "Option -$OPTARG requires an argument"
usage
exit 1;
;;
esac
done

if [ "$LOCATION" == "" ];
then
INSTALL_PATH=/usr/lpp;
fi

if [ "$INSTALL_PATH" == "" ];
then
echo -e "Option: -p is missing"
usage
exit 1;
fi

mkdir -p /var/log >/dev/null 2>/dev/null
echo "HTX intall started on `date` >>>>>>>>>>>>" >> ${INSTALL_LOG_FILE}
if type "lsb_release" >> ${INSTALL_LOG_FILE} 2>&1; then
echo -e "\nYour Install System:"
if [ -f /etc/redhat-release ] ; then
OS="RedHat"
elif [ -f /etc/SuSE-release ] ; then
OS="SUSE"
elif [ -f /etc/debian_version ] ; then
OS="Ubuntu"
fi
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$(lsb_release -sr)
echo -e "Distro:$OS"
echo -e "Version:$VER"
echo -e "Arch:$ARCH"
else
echo -e "\nYour Install System:"
if [ -f /etc/redhat-release ] ; then
OS="RedHat"
elif [ -f /etc/SuSE-release ] ; then
OS="SUSE"
elif [ -f /etc/debian_version ] ; then
OS="Ubuntu"
fi
ARCH=$(uname -m)
echo -e "Distro:$OS"
echo -e "Arch:$ARCH"
fi

CURRENT_OS="Compiledon:$OS"
if [ $CURRENT_OS != $(cat os_build | grep Compiledon) ];
then
echo -e "\nWarning:It is observed that HTX is $(cat os_build | grep Compiledon) and you are trying to install on top of $OS..." | tee -a ${INSTALL_LOG_FILE}
fi
if [ -f /var/log/htx_install_path ]; then
HTX_INSTALL=$(cat /var/log/htx_install_path)
echo -e "\nHTX already installed in: $HTX_INSTALL" | tee -a ${INSTALL_LOG_FILE}
if [ "$FORCE" == "" ];
then
echo -e "Exiting..."
exit 0;
fi
if [ $FORCE -eq 1 ];
then
echo -ne "\nRemoving installed HTX..." | tee -a ${INSTALL_LOG_FILE}
./uninstaller.sh >> ${INSTALL_LOG_FILE}
if [ $? -eq 0 ]; then
echo -e "[OK]" | tee -a ${INSTALL_LOG_FILE}
else
echo -e "[FAILED]" | tee -a ${INSTALL_LOG_FILE}
echo -e "\n Uninstall failed..Please uninstall manually and restart installation. Refer '${INSTALL_LOG_FILE}' file for logs" | tee -a ${INSTALL_LOG_FILE}
exit 1;
fi
else
exit 0;
fi
fi
if [ "$LOCATION" == "" ];
then
echo -e "\nInstalling HTX in default path:/usr/lpp/htx..." | tee -a ${INSTALL_LOG_FILE}
else
echo -e "\nInstalling HTX in $INSTALL_PATH/htx..." | tee -a ${INSTALL_LOG_FILE}
fi
echo -ne "\nCreating 'htx' user..." | tee -a ${INSTALL_LOG_FILE}
if ! id -g htx > /dev/null 2>&1 ; then groupadd htx -o -g 0 > /dev/null 2>&1 ; fi
if [ $? -ne 0 ]; then
groupdel htx > /dev/null 2>&1 ;
groupadd htx -o -g 0 > /dev/null 2>&1 ;
fi
sync
sleep 1
if ! id htx > /dev/null 2>&1 ; then mkdir -p $INSTALL_PATH/htx; useradd -g htx -d $INSTALL_PATH/htx -s /bin/bash -u 0 -o htx > /dev/null 2>&1 ; fi
rm -rf $INSTALL_PATH/htx
echo -e "[OK]" | tee -a ${INSTALL_LOG_FILE}
mkdir -p /var/log
mkdir -p $INSTALL_PATH
echo -ne "\nExtracting htx.tar.gz to $INSTALL_PATH..." | tee -a ${INSTALL_LOG_FILE}
tar xvzf htx.tar.gz -C $INSTALL_PATH > /dev/null 2>&1
echo -e "[OK]" | tee -a ${INSTALL_LOG_FILE}
INSTALL_PATH_HTX=$INSTALL_PATH/htx
echo $INSTALL_PATH_HTX > /var/log/htx_install_path
echo -ne "\nFinishing Installation..." | tee -a ${INSTALL_LOG_FILE}
[[ -f $INSTALL_PATH/htx/etc/scripts/htx.d ]] && cp -f $INSTALL_PATH/htx/etc/scripts/htx.d /etc/init.d
echo -e "[OK]" | tee -a ${INSTALL_LOG_FILE}
echo -ne "\nCopying HTX Binaries..." | tee -a ${INSTALL_LOG_FILE}
ln -sf /usr/bin/perl /bin/perl >> ${INSTALL_LOG_FILE} 2>&1
if [ "$OS" != "RedHat" ];
then
ln -sf /usr/bin/awk /bin/awk >> ${INSTALL_LOG_FILE} 2>&1
fi
ln -sf $INSTALL_PATH/htx/bin/htxcmdline /bin/htxcmdline
ln -sf $INSTALL_PATH/htx/bin/htxcmdline /bin/hcl
ln -sf $INSTALL_PATH/htx/bin/htxscreen /bin/htxscreen
ln -sf $INSTALL_PATH/htx/bin/htxscreen /bin/htxmenu
ln -sf $INSTALL_PATH/htx/etc/scripts/ver /bin/ver
cp $INSTALL_PATH/htx/htx_binaries/bin/* /usr/bin/
cp $INSTALL_PATH/htx/htx_binaries/sbin/* /usr/sbin/
echo -e "[OK]" | tee -a ${INSTALL_LOG_FILE}

if [ "$OS" != "Ubuntu" ];
then
echo -ne "\nCreating htx.d.service file..." | tee -a ${INSTALL_LOG_FILE}
echo "[Unit]" > /usr/lib/systemd/system/htx.d.service
echo -e "Description=htx Daemon\n" >> /usr/lib/systemd/system/htx.d.service
echo "[Service]" >> /usr/lib/systemd/system/htx.d.service
echo "Type=forking" >> /usr/lib/systemd/system/htx.d.service
echo -e "ExecStart=${INSTALL_PATH}/htx/etc/scripts/htxd_run" >> /usr/lib/systemd/system/htx.d.service
echo -e "ExecStop=${INSTALL_PATH}/htx/etc/scripts/htxd_shutdown" >> /usr/lib/systemd/system/htx.d.service
echo -e "TasksMax=infinity\n" >> /usr/lib/systemd/system/htx.d.service
echo "[Install]" >> /usr/lib/systemd/system/htx.d.service
echo "WantedBy=multi-user.target" >> /usr/lib/systemd/system/htx.d.service
echo -e " [OK]" | tee -a ${INSTALL_LOG_FILE}
fi
echo -ne "\nAdding HTX Daemon(htxd) as service..." | tee -a ${INSTALL_LOG_FILE}
echo -e "${INSTALL_PATH}/htx/etc/scripts/htx_setup.sh" > ${INSTALL_PATH}/htx/.bash_profile
nimesis_present=`ps -ef | grep nimesis | grep -v grep | wc -l`
if [ $nimesis_present -eq 0 ] && [ ! "$DONTSTARTHTXD" = 1 ]
then
if [ "$OS" == "Ubuntu" ];
then
update-rc.d htx.d defaults >> ${INSTALL_LOG_FILE} 2>&1
/etc/init.d/htx.d start >> ${INSTALL_LOG_FILE} 2>&1
else
systemctl enable htx.d >> ${INSTALL_LOG_FILE} 2>&1
systemctl start htx.d >> ${INSTALL_LOG_FILE} 2>&1
systemctl status htx.d >> ${INSTALL_LOG_FILE} 2>&1
fi
fi
echo -e "[OK]" | tee -a ${INSTALL_LOG_FILE}
echo -ne "\nChecking HTX daemon status..." | tee -a ${INSTALL_LOG_FILE}
if pgrep -x "htxd" >> ${INSTALL_LOG_FILE} 2>&1
then
echo -e "[Running]" | tee -a ${INSTALL_LOG_FILE}
echo -e "\nHTX install completed..Now exiting." | tee -a ${INSTALL_LOG_FILE}
echo -e "HTX install completed on `date` <<<<<<<<<<<<" >> ${INSTALL_LOG_FILE} 2>&1
echo -e "\nHTX Installed version\n" >> ${INSTALL_LOG_FILE} 2>&1
ver >> ${INSTALL_LOG_FILE} 2>&1
exit 0;
else
echo -e "[Not Running]" | tee -a ${INSTALL_LOG_FILE}
echo -e "\nHTX Install failed..Please check log file '${INSTALL_LOG_FILE}'."
exit 1;
fi

0 comments on commit 50879ad

Please sign in to comment.