Category:Sharedops

From campisano.org
Jump to navigation Jump to search

Shared ops template

Useful template/script to install third part software in an alternative way (shared, reusable for update, not editable by running users, fixing permissions and removing suid)

# shared/opt install schema v1.4.1

#### as common user ####
# setup env vars
export SOFTWARE_PATH="</home/shared/opt/software>"              # to customize
export NAME="<SOFTWARE-NAME>"                                   # to customize
export VERSION="<X.Y.Z>"                                        # to customize
export URL="<DOWNLOAD_URL/FILE_${VERSION}.EXT>"                 # to customize
export INSTALL_USER="$(id -n -u):$(id -n -g)"
su - -w SOFTWARE_PATH,NAME,VERSION,INSTALL_USER

#### as root ####
# generic dependencies
apt-get -qq -y install wget coreutils findutils
# dependencies
apt-get -qq -y install <PACKAGES>                               # to customize
# paths
mkdir -p "${SOFTWARE_PATH}/tmp_install/" "${SOFTWARE_PATH}/${NAME}_${VERSION}/"
chown "${INSTALL_USER}" "${SOFTWARE_PATH}/tmp_install/" "${SOFTWARE_PATH}/${NAME}_${VERSION}"
exit

#### as common user ####
umask 0027
cd "${SOFTWARE_PATH}/tmp_install"
wget -c --no-check-certificate "${URL}"
<EXTRACT -x?f FILE_${VERSION}.EXT>                              # to customize
cd <FOLDER>                                                     # to customize
# configure
CFLAGS="-g0 -O3 -march=native -s" ./configure --prefix="${SOFTWARE_PATH}/${NAME}_${VERSION}"    # to customize
make
make install
su - -w SOFTWARE_PATH,NAME,VERSION

#### as root ####
cd "${SOFTWARE_PATH}"
chown -R root:users "${NAME}_${VERSION}"
find "${NAME}_${VERSION}" -type d -exec chmod a-s,u+rwx,g+rx,g-w,o-rwx {} \;
find "${NAME}_${VERSION}" -type f -exec chmod a-s,u+rw,g+r,g-w,o-rwx {} \;
rm -rf tmp_install
ln -s -f -T "${NAME}_${VERSION}" "${NAME}"
exit

#### as common user ####
cd
"${SOFTWARE_PATH}/${NAME}/<BIN_PATH>"                           # to customize