Need assistance in converting Makefile to Shell script - shell

Need your help to convert code in Makefile to Shell script? Please help as I am new to both MakeFile and Shell Scripting.Thanks.
Sample Code:
include Configfile
.PHONY: config-arch asoc-tool clone-repo generate-irx api-login \
upload-file get-app run-scan show-scan-id get-asset-group create-app
config-arch:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
asoc-tool: config-arch
$(eval DIR := $(shell pwd))
curl -o client.zip $(APPSCAN_TOOL)
mkdir client ; mkdir tool
unzip -qq client.zip -d client
cd client ; ls | xargs -I {} sh -c "cp -r {}/* $(DIR)/tool"
rm -rf client
clone-repo:
git clone $(GIT_REPO)
# Generates the irx file for icp-cert-manager.
generate-irx:
$(eval DIR := $(shell pwd))
cd $(PROJECT_NAME); $(DIR)/tool/bin/appscan.sh prepare $(flag)

#!/bin/sh
# config-arch
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
# asoc-tool
curl -o client.zip $(APPSCAN_TOOL)
mkdir client ; mkdir tool
unzip -qq client.zip -d client
cd client ; ls | xargs -I {} sh -c "cp -r {}/* ./tool"
rm -rf client
# clone repo
git clone ${GIT_REPO} # you should overwrite ${GIT_REPO} to your git repo, maybe from Configfile
# generate-irx
cd $(PROJECT_NAME)
./tool/bin/appscan.sh prepare ${flag} # you should check your ${flag}, maybe from Configfile

Related

chmod +x cant find build.sh file

I have been trying to make a VCS in C++ but the build file is not running in my LINUX(Ubuntu).
It is prompting the above message.
my build file is as follows:
#!/bin/bash
sudo apt-get update
udo apt-get install openssl -y
sudo apt-get install libssl-dev -y
mkdir -p ~/imperium/bin
cp imperium.sh ~/imperium
cd ..
make
cd ~/imperium/bin || echo "error"
chmod +x main
cd ..
if grep -q "source $PWD/imperium.sh" "$PWD/../.bashrc" ; then
echo 'already installed bash source';
else
echo "source $PWD/imperium.sh" >> ~/.bashrc;
fi
my imperium.sh file is also as follows:
function imperium(){
DIR=$PWD
export dir=$DIR
cd ~/imperium/bin || echo "Error"
./main "$#"
cd "$DIR" || echo "Error"
}
I will be heavily obliged if any one can solve this problem of mine. After chmod I have been doing:
./build.sh but its prompting that build.sh file does not exists.
For me it seems you have a typo right in the 3rd row "udo" ->
"sudo".
Also, You should avoid using cd .. and use relative paths for
the commands.

export PATH inside a bash script

I am install ffmpeg from source in my bash script.However although i have source /etc/environment after i install ffmpeg dependancies, ffmpeg compilation isn't able to see the dependencies yasm/nasm.After the script is fully run i need to manually run source /etc/environment and then rerun compile ffmpeg again.
Full script is shown below
#!/bin/bash
#####################################################
# #
# Author : Khavish Anshudass Bhundoo #
# License : MIT #
# Install dependencies needed for compression test #
#####################################################
echo "This script will install softwares needed to run compression_test.sh"
if [ "$EUID" -ne 0 ]
then echo "This script must be run as root user....exiting"
exit
fi
rm -f /var/cache/yum/timedhosts.txt
yum -y -q install redhat-lsb-core deltarpm
version=$(lsb_release -sr | sed 's/\.[^ ]*/ /g') #Version = 7
echo "Setting Up EPEL and remi Repositories"
{
yum install -y -q epel-release
rpm --quiet --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
rpm --quiet --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm --quiet -ivh http://rpms.famillecollet.com/enterprise/remi-release-${version:0:1}.rpm
} &> /dev/null
echo "Updating System...This may take a while"
{
yum clean all &> /dev/null
package-cleanup --cleandupes > /dev/null
yum -y -q update
systemctl daemon-reload
} &> /dev/null
#Installing some commonly used tools
echo "Installing tools needed by script or compilation"
{
yum -y -q install deltarpm
yum clean all &> /dev/null
yum -y groupinstall "Development Tools" &> /dev/null
rpm --quiet -ivh https://download-mirror.savannah.gnu.org/releases/datamash/datamash-1.2-1agn.el6.x86_64.rpm
yum -y -q install nano wget make htop mlocate unzip git bc parallel gnuplot libpng-devel ninja-build
updatedb
} 2>&1 | grep -v "already installed and latest version"
echo "Install bazel"
{
wget -q https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo -P /etc/yum.repos.d/
yum -y -q install bazel
} &> /dev/null
#Update path for all users
#echo "export PATH=\$PATH:/usr/local/bin" >> /etc/profile
echo "export PATH=$PATH:/usr/local/bin" >> /etc/environment
source /etc/environment
#Optimize OpenCV install by not relying on third party script to make full use of Ninja and make -j
echo "Installing OpenCV(This might take a while)"
{
cd "$HOME"
git clone https://github.com/jayrambhia/Install-OpenCV
cd Install-OpenCV
cd RedHat
chmod +x *
sed -i '1s/^/version="2.4.13"\n/' opencv_install.sh
sed -i '1s/^/downloadfile="opencv-2.4.13.zip"\n/' opencv_install.sh
sed -i '1s/^/downloadfile="opencv-2.4.13.zip"\n/' opencv_install.sh
sed -i '/cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ../c\cmake -G Ninja -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..' opencv_install.sh
./opencv_install.sh
} &> /dev/null
number_of_cores=$(nproc)
shopt -s expand_aliases
alias make="/usr/bin/make -j$number_of_cores"
echo "Installing libjpeg"
{
cd "$HOME"
git clone https://github.com/thorfdbg/libjpeg
cd libjpeg
make
cp jpeg /usr/local/bin
} &> /dev/null
echo "Installing butteraugli"
{
cd "$HOME"
git clone https://github.com/google/butteraugli
cd butteraugli
bazel build -c opt //:butteraugli
cd bazel-bin
chmod +x butteraugli
cp butteraugli /usr/local/bin
} &> /dev/null
echo "Installing guetzli"
{
cd "$HOME"
git clone https://github.com/google/guetzli
cd guetzli
bazel build -c opt //:guetzli
chmod +x bazel-bin/guetzli
cp bazel-bin/guetzli /usr/local/bin
} &> /dev/null
echo "Installing Ssimulacra"
{
cd "$HOME"
git clone https://github.com/cloudinary/ssimulacra
cd ssimulacra
make
chmod +x ssimulacra
cp ssimulacra /usr/local/bin
} &> /dev/null
echo "Installing Imagemagick7"
{
yum --enablerepo=remi -y -q install ImageMagick7*
} &> /dev/null
echo "Installing Pik"
{
cd "$HOME"
git clone https://github.com/google/pik
cd pik
git submodule init && git submodule update
make
cd bin
chmod +x *
cp * /usr/local/bin
} &> /dev/null
echo "Installing Webp"
{
cd "$HOME"
wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.6.1-linux-x86-64.tar.gz
tar -xzf libwebp-0.6.1-linux-x86-64.tar.gz
cd libwebp-0.6.1-linux-x86-64/bin
cp * /usr/local/bin
} &> /dev/null
echo "Installing ffmpeg(This might take some time)"
{
cd "$HOME"
yum -y -q install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
#NASM
yum remove -y nasm && hash -r
cd ~/ffmpeg_sources
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2
tar xjvf nasm-2.13.02.tar.bz2
cd nasm-2.13.02
./autogen.sh
./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/local/bin"
make
make install
source /etc/environment
#Yasm
cd ~/ffmpeg_sources
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/local/bin"
make
make install
source /etc/environment
#x264
cd ~/ffmpeg_sources
git clone --depth 1 http://git.videolan.org/git/x264
cd x264
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/local/bin" --enable-static
make
make install
source /etc/environment
#x265
cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
cmake -G "Unix Makefiles" -DBIN_INSTALL_DIR="/usr/local/bin" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install
cp x265 /usr/local/bin
source /etc/environment
#libfdk_aac
cd ~/ffmpeg_sources
git clone --depth 1 https://github.com/mstorsjo/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
source /etc/environment
#libmp3lame
cd ~/ffmpeg_sources
curl -O -L https://phoenixnap.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xzvf lame-3.100.tar.gz
cd lame-3.100
./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/local/bin" --disable-shared --enable-nasm
make
make install
source /etc/environment
#libopus
cd ~/ffmpeg_sources
curl -O -L https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz
tar xzvf opus-1.2.1.tar.gz
cd opus-1.2.1
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
source /etc/environment
#libogg
cd ~/ffmpeg_sources
curl -O -L http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.gz
tar xzvf libogg-1.3.3.tar.gz
cd libogg-1.3.3
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
source /etc/environment
#libvorbis-1.3.5
cd ~/ffmpeg_sources
curl -O -L http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz
tar xzvf libvorbis-1.3.5.tar.gz
cd libvorbis-1.3.5
./configure --prefix="$HOME/ffmpeg_build" --with-ogg="$HOME/ffmpeg_build" --disable-shared
make
make install
source /etc/environment
#libvpx
cd ~/ffmpeg_sources
git clone --depth 1 -b v1.6.1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make
make install
source /etc/environment
#ffmpeg
cd ~/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs=-lpthread \
--extra-libs=-lm \
--bindir="/usr/local/bin" \
--enable-gpl \
--enable-libfdk_aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
make
make install
make distclean
hash -r
source /etc/environment
} &> /dev/null
echo "Installing AV1"
{
yum -y -q install cmake3
cd "$HOME"
git clone https://aomedia.googlesource.com/aom
cd aom
aom_directory=$(pwd)
mkdir -p ../aom_build && cd ../aom_build
cmake3 "$aom_directory"
make
cp aomdec aomenc /usr/local/bin
} &> /dev/null
echo "Installing OpenJPEG"
{
cd "$HOME"
wget https://github.com/uclouvain/openjpeg/releases/download/v2.3.0/openjpeg-v2.3.0-linux-x86_64.tar.gz
tar -xzf openjpeg-v2.3.0-linux-x86_64.tar.gz
cd openjpeg-v2.3.0-linux-x86_64/bin
cp * /usr/local/bin
} &> /dev/null
echo "Installing FLIF"
{
cd "$HOME"
wget https://github.com/FLIF-hub/FLIF/archive/v0.3.tar.gz -O flif_v0.3.tar.gz
tar -xzf flif_v0.3.tar.gz
cd FLIF-0.3
make && make install
} &> /dev/null
echo "Installing BPG"
{
yum install -y -q SDL*
cd "$HOME"
wget -q https://bellard.org/bpg/libbpg-0.9.7.tar.gz
tar -xzf libbpg-0.9.7.tar.gz
cd libbpg-0.9.7
sed -i '/#USE_JCTVC=y/c\USE_JCTVC=y' Makefile
make && make install
} &> /dev/null
echo "Installing MozJPEG"
{
cd "$HOME"
wget -q https://github.com/mozilla/mozjpeg/releases/download/v3.2/mozjpeg-3.2-release-source.tar.gz
tar -xzf mozjpeg-3.2-release-source.tar.gz
cd mozjpeg
autoreconf -fiv
./configure
make && make install
cd /opt/mozjpeg/bin/
cp * /usr/local/bin
} &> /dev/null
source /etc/environment
Instead of:
echo "export PATH=$PATH:/usr/local/bin" >> /etc/environment
source /etc/environment
try this:
echo "export PATH=/usr/local/bin:$PATH" >> /etc/environment
source /etc/environment

Failed to Call Access Method Exception when Creating a MedicationOrder in FHIR

I am using this http://fhirtest.uhn.ca/baseDstu2 test FHIR server and it worked okay so far.
Now I am getting an HTTP-500 - Failed to Call Access Method exception.
Anyone has any idea on what has gone wrong?
This happens frequently. Probably because someone tested weird queries or similar that put the server in an unstable status.
I suggest posting a comment in https://chat.fhir.org/#narrow/stream/hapi to get the server restarted,
or install http://hapifhir.io/doc_cli.html which does basically the same but you have full control.
I built a Dockerfile:
FROM debian:sid
MAINTAINER Günter Zöchbauer <guenter#yyy.com>
ENV DEBIAN_FRONTEND noninteractive
RUN \
apt-get -q update && \
DEBIAN_FRONTEND=noninteractive && \
apt-get install --no-install-recommends -y -q \
apt-transport-https \
apt-utils \
wget \
bzip2 \
default-jdk
# net-tools sudo procps telnet
RUN \
apt-get update && \
rm -rf /var/lib/apt/lists/*
https://github.com/jamesagnew/hapi-fhir/releases/download/v2.0/hapi-fhir-2.0-cli.tar.bz2 && \
ADD hapi-* /hapi_fhir_cli/
RUN ls -la
RUN ls -la /hapi_fhir_cli
ADD prepare_server.sh /hapi_fhir_cli/
RUN \
cd /hapi_fhir_cli && \
bash -c /hapi_fhir_cli/prepare_server.sh
ADD start.sh /hapi_fhir_cli/
WORKDIR /hapi_fhir_cli
EXPOSE 5555
ENTRYPOINT ["/hapi_fhir_cli/start.sh"]
Which requires in the same directory as the Dockerfile
prepare_server.sh
#!/usr/bin/env bash
ls -la
./hapi-fhir-cli run-server --allow-external-refs &
while ! timeout 1 bash -c "echo > /dev/tcp/localhost/8080"; do sleep 10; done
./hapi-fhir-cli upload-definitions -t http://localhost:8080/baseDstu2
./hapi-fhir-cli upload-examples -c -t http://localhost:8080/baseDstu2
start.sh
#!/usr/bin/env bash
cd /hapi_fhir_cli
./hapi-fhir-cli run-server --allow-external-refs -p 5555
Build
docker build myname/hapi_fhir_cli_dstu2 -t . #--no-cache
Run
docker run -d -p 5555:5555 [image id from docker build]
Hope this helps.

How do I add an updated ghostscript to AWS EC2 Instance with Amazon Linux AMI

How can I get 9.20 - the current version?
(I'm doing the research and will answer as I finish.)
This answer is an update to the now stale answer here, with a few extra details and a reference to the current repo location.
This may be obvious to the more experienced, but this is intended to help those less experienced with CLI/make/gcc who just need gs.
First set up gcc-c++ if you haven't already [Are all packages necessary? Last two seem to be not needed.]:
sudo yum install -y gcc gcc-c++ compat-gcc-32 compat-gcc-32-c++
Then download, make and install ghostscript:
wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/ghostscript-9.20.tar.gz
tar -zxvf ghostscript-9.20.tar.gz
cd ghostscript-9.20
./configure --prefix=/usr --enable-dynamic --disable-compile-inits --with-system-libtiff
make
make so
sudo make install
sudo chmod go+w /usr/include/ghostscript/
sudo make soinstall && install -v -m644 base/*.h /usr/include/ghostscript && sudo ln -v -s ghostscript /usr/include/ps
sudo ln -sfv ../ghostscript/9.20/doc /usr/share/doc/ghostscript-9.20
cd ..
wget http://sourceforge.net/projects/gs-fonts/files/latest/download?source=files --output-document=ghostscript-fonts-std-8.11.tar.gz
sudo tar -xvf ghostscript-fonts-std-8.11.tar.gz -C /usr/share/ghostscript
fc-cache -v /usr/share/ghostscript/fonts/
sudo mkdir /usr/include/ghostscript/
sudo chmod go-w /usr/include/ghostscript/
ghostscript -v
gs -v
You could put the source code on the instance and compile it.....
Met an error when ran
sudo chmod go+w /usr/include/ghostscript/
because the folder didn't exist yet.
So I did minor adjustment to the command order:
wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/ghostscript-9.20.tar.gz
tar -zxvf ghostscript-9.20.tar.gz
cd ghostscript-9.20
./configure --prefix=/usr --enable-dynamic --disable-compile-inits --with-system-libtiff
make
make so
sudo make install
sudo mkdir /usr/include/ghostscript/
sudo chmod go+w /usr/include/ghostscript/
sudo make soinstall && install -v -m644 base/*.h /usr/include/ghostscript && sudo ln -v -s ghostscript /usr/include/ps
sudo ln -sfv ../ghostscript/9.20/doc /usr/share/doc/ghostscript-9.20
cd ..
wget http://sourceforge.net/projects/gs-fonts/files/latest/download?source=files --output-document=ghostscript-fonts-std-8.11.tar.gz
sudo tar -xvf ghostscript-fonts-std-8.11.tar.gz -C /usr/share/ghostscript
fc-cache -v /usr/share/ghostscript/fonts/
sudo chmod go-w /usr/include/ghostscript/
ghostscript -v
gs -v

sh script to build from source Ubuntu

Im trying to automate some dependency installing from an sh script, however, I feel that not all commands are getting through.
Here is an example:
#!/bin/sh
cd /Downloads
sudo wget https://github.com/tpaviot/oce/archive/OCE-0.16.1.tar.gz
sudo tar -xvf OCE-0.16.1.tar.gz
cd oce-OCE-0.16.1/
sudo mkdir build
cd build
sudo cmake ../
sudo make
sudo make install/strip
Is this valid in a .sh script?

Resources