Sunday, 29 August 2021

PowerShell on Ubuntu

Commands to connect from Linux to Windows Server


Enter-PSSession -ComputerName <IPADDR> -Credential oneflorida\administrator -Authentication Negotiate

Invoke-Command -ComputerName  <IPADDR>  -ScriptBlock { get-ChildItem c:\ } -Credential oneflorida\administrator -Authentication Negotiate 


Install PowerShell

# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of products
sudo apt-get update
# Enable the "universe" repositories
sudo add-apt-repository universe
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh
Fix one issues with the library
ldd /opt/microsoft/powershell/7/libmi.so
   linux-vdso.so.1 (0x00007fff9617c000)
   libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2a180a2000)
   libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2a1809c000)
   libpam.so.0 => /lib/x86_64-linux-gnu/libpam.so.0 (0x00007f2a1808a000)
   libssl.so.1.0.0 => not found
   libcrypto.so.1.0.0 => not found
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2a17e98000)
   /lib64/ld-linux-x86-64.so.2 (0x00007f2a182ad000)
   libaudit.so.1 => /lib/x86_64-linux-gnu/libaudit.so.1 (0x00007f2a17e6a000)
   libcap-ng.so.0 => /lib/x86_64-linux-gnu/libcap-ng.so.0 (0x00007f2a17e62000)
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /lib/x86_64-linux-gnu/libssl.so.1.0.0
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
apt install gss-ntlmssp

Wednesday, 18 August 2021

lxc container oracle/centos 8 not getting macvlan ip address


This has been beating us up here as well. Today, I found an answer. It may not be /the/ answer, but it does work. The problem is with CentOS 8 and the complete replacement of network-scripts with NetworkManager scripts. I know that there have been others searching for an answer to this in vain, so I’m offering up what I’ve found. Do with it what you may!

  1. Create a centos8 container using the defaults (i.e., don’t apply macvlan to them on the build) so have it use the bridge interface, which is the default

  2. Next get into the container

lxc exec [container_name] bash

  1. Next install the old network-scripts package

dnf install network-scripts

  1. Next stop Network Manager

systemctl stop NetworkManager

  1. Now make sure it doesn’t start on container startup

systemctl disable NetworkManager

  1. Next enable the Network service (part of the network-scripts package)

systemctl enable network.service

  1. Exit out of the container

  2. Now apply (or assign) your macvlan template to the container

lxc profile apply [container_name] default,macvlan - Get into the container and modify the interface vi /etc/sysconfig/network-scripts/ifcfg-eth0

and set the interface with the IP or dhcp, depending on your setup. Save the configuration and get out.

  1. Test that the interface comes up

ifup eth0

Monday, 2 August 2021

PUMMER Deployment

Script to Deploy PUM Images Automatically

Main: pummer.ksh
==============
process_id=$(echo $$);
clear
echo ""
echo ""
echo ""

deploy_pum_image()
{

# Clone Container
# MODULE="CRM"
# bugid="31046243"
# NUMBER=3

# Prepare the container

echo "Destroying the existing ${MODULE}${bugid} container, if it exists \n"
    
lxc-ls --active
lxc-stop -k -n ${MODULE}${bugid}
lxc-destroy -n ${MODULE}${bugid}

echo "Cloning and Creating ${MODULE}${bugid} container"
lxc-clone oraclepumtemplate ${MODULE}${bugid}

echo "Preparing ${MODULE}${bugid} container"
mkdir -p /container/${MODULE}${bugid}/rootfs/pumdownload     
unalias cp;cp -rf /container/templates/config_template /container/${MODULE}${bugid}/config
sed -i "s/"__HOSTNAME__"/"${MODULE}${bugid}"/g" /container/${MODULE}${bugid}/config
cat /container/${MODULE}${bugid}/config

# Start the container

lxc-start -n ${MODULE}${bugid} -d -o /container/${MODULE}${bugid}.log -l DEBUG

# Deploy PUM IMAGE
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- chmod +x /root/scripts/pum_deploy.sh
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- /root/scripts/pum_deploy.sh ${NUMBER} ${bugid}

}

echo "==========================================="
echo "Welcome to PUMMER - PUM Deployment Manager"
echo "==========================================="

read -p 'Please Enter your Oracle ID:  ' uservar
read -sp 'Password: ' passvar
echo ""
echo ""
echo -n "Validating your Credentials: "
if [ $(/usr/bin/java -jar /root/pumdump/getMOSPatch.jar MOSUser=$uservar MOSPass=$passvar platform=226P download=all patch=32356044|grep "ERROR: Invalid credentials"|wc -l) -eq 1 ]; then
        echo -n "Invalid Credentials"
else
        echo -n " All Good"
        echo ""
        echo ""

        #read -p 'Application Module Number? 1-FSCM, 2-HCM, 3-CRM, 4-PORTAL:  ' module

                while true
                do
                read -p "Module Number? 1-FSCM, 2-HCM, 3-CRM, 4-PORTAL, 5-ELM, 6-CampusSolutions:  " NUMBER
                case $NUMBER in
                                1) MODULE="FSCM"; break;;
                                2) MODULE="HCM"; break;;
                                3) MODULE="CRM"; break;;
                                4) MODULE="PORTAL"; break;;
5) MODULE="ELM"; break;;
5) MODULE="CS"; break;;
                                *) echo "Not a valid option" ; continue ;;
                esac
                done

        echo ""

                while true
                do
                read -p 'Please Enter PUM / Bug ID:  ' bugid
                /usr/bin/java -jar /root/pumdump/getMOSPatch.jar MOSUser=$uservar MOSPass=$passvar platform=226P patch=$bugid > /tmp/${bugid}_${process_id}.txt 2>/dev/null

                                if [ $(cat /tmp/${bugid}_${process_id}.txt|grep zip|wc -l) -gt 5 ];
                                then
                                        break;
                                else
                                        continue
                                fi
                done

fi

 cat /tmp/${bugid}_${process_id}.txt

 echo "Please confirm if you want to move forward with the download of the BUG ID : $bugid and create a PUM instance ?"

read -r -p "Are you sure? [y/N] " response

if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
                mkdir -p /pumdownloads/${MODULE}/${bugid} && cd /pumdownloads/${MODULE}/${bugid}

                if [ -f /pumdownloads/${MODULE}/${bugid}/ALL_GOOD_FILES.txt ]
                then
                        echo ""
                        echo ""
                        echo "Good News: PUM Image ${MODULE} has been already downloaded no need to download once again. :)"
                        echo "Thanks, PUMMER will sent email notification along with the URL to your oracle $uservar once the PUM image is successfully deployed"
deploy_pum_image
                        echo ""
                        echo ""
                else
cd /pumdownloads/${MODULE}/${bugid}
nohup /container/scripts/download_deploy_pum_image.ksh uservar passvar bugid MODULE NUMBER > /pumdownloads/download_deploy_pum_image_${bugid}_${process_id}.log 2>&1 &
# deploy_pum_image
touch /pumdownloads/${MODULE}/${bugid}/ALL_GOOD_FILES.txt
                        echo ""
                        echo ""
                        echo "Thanks, PUMMER will sent email notification along with the URL to your oracle $uservar once the PUM image is successfully deployed"
                        echo ""
                        echo ""
                fi
else
 echo "Ok, your request is cancelled!"
fi



[root@localhost scripts]# cat download_deploy_pum_image.ksh
uservar=$1
passvar=$2
bugid=$3
MODULE=$4
NUMBER=$5

deploy_pum_image()
{

# Clone Container
# MODULE="CRM"
# bugid="31046243"
# NUMBER=3

# Prepare the container

echo "Destroying the existing ${MODULE}${bugid} container, if it exists \n"

        lxc-ls --active
        lxc-stop -k -n ${MODULE}${bugid}
        lxc-destroy -n ${MODULE}${bugid}

echo "Cloning and Creating ${MODULE}${bugid} container"

        lxc-clone oraclepumtemplate ${MODULE}${bugid}

echo "Preparing ${MODULE}${bugid} container"

        mkdir -p /container/${MODULE}${bugid}/rootfs/pumdownload
        unalias cp;cp -rf /container/templates/config_template /container/${MODULE}${bugid}/config
        sed -i "s/"__HOSTNAME__"/"${MODULE}${bugid}"/g" /container/${MODULE}${bugid}/config
        cat /container/${MODULE}${bugid}/config

# Start the container

lxc-start -n ${MODULE}${bugid} -d -o /container/${MODULE}${bugid}.log -l DEBUG

# Deploy PUM IMAGE
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- chmod +x /root/scripts/pum_deploy.sh
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- /root/scripts/pum_deploy.sh ${NUMBER} ${bugid}

}


/usr/bin/java -jar /root/pumdump/getMOSPatch.jar MOSUser=$uservar MOSPass=$passvar download=all platform=226P patch=$bugid; > /pumdownloads/${bugid}_${process_id}.log
touch /pumdownloads/${MODULE}/${bugid}/ALL_GOOD_FILES.txt
deploy_pum_image



# pum_deploy.sh
==============

[root@localhost scripts]# cat pum_deploy.sh
#pum_deploy.sh <APPLICATION> <PUMIMAGEID>
# 1-FSCM, 2-HCM, 3-CRM, 4-PORTAL, 5-ELM, 6-CampusSolutions

TEMPLATES=/root/scripts/templates
APPLICATION=$1
PUMIMAGE=$2
# /etc/hosts file update
if [ $(/sbin/ifconfig|grep eth1|wc -l) -eq 1 ]
then
        /sbin/ifconfig| grep eth1 -A 1|grep inet|awk -v host=$(hostname) '{ print "127.0.0.1 localhost\n"  $2 " " host }' > /etc/hosts
else
        echo "eth1 Not Found"
fi

if [ $APPLICATION -eq 1 ]
then
        # FSCM execution
        if [ -d /pumdownload/pumdownloads/FSCM/$PUMIMAGE ]; then
                cd /pumdownload/pumdownloads/FSCM/$PUMIMAGE/ && unzip -o *_1of*.zip
                cd /pumdownload/pumdownloads/FSCM/$PUMIMAGE/setup
                sh psft-dpk-setup.sh --silent --response_file=$TEMPLATES/fscm_response.txt --customization_file=$TEMPLATES/fscm_psft_customizations.yaml
        else
                echo "Sorry the PUM Image $PUMIMAGE Not Found for FSCM"
                exit 5
        fi
elif [ $APPLICATION -eq 2 ]; then
        # HCM execution
        if [ -d /pumdownload/pumdownloads/HCM/$PUMIMAGE ]; then
                cd /pumdownload/pumdownloads/HCM/$PUMIMAGE/ && unzip -o *_1of*.zip
                cd /pumdownload/pumdownloads/HCM/$PUMIMAGE/setup
                sh psft-dpk-setup.sh --silent --response_file=$TEMPLATES/hcm_response.txt --customization_file=$TEMPLATES/hcm_psft_customizations.yaml
        else
                echo "Sorry the PUM Image $PUMIMAGE Not Found for HCM"
                exit 5
        fi
elif [ $APPLICATION -eq 3 ]; then
        # CRM execution
        if [ -d /pumdownload/pumdownloads/CRM/$PUMIMAGE ]; then
                cd /pumdownload/pumdownloads/CRM/$PUMIMAGE/ && unzip -o *_1of*.zip
                cd /pumdownload/pumdownloads/CRM/$PUMIMAGE/setup
                sh psft-dpk-setup.sh --silent --response_file=$TEMPLATES/crm_response.txt --customization_file=$TEMPLATES/crm_psft_customizations.yaml
        else
                echo "Sorry the PUM Image $PUMIMAGE Not Found for CRM"
                exit 5
        fi
elif [ $APPLICATION -eq 4 ]; then
        # PORTAL execution
        if [ -d /pumdownload/pumdownloads/PORTAL/$PUMIMAGE ]; then
                cd /pumdownload/pumdownloads/PORTAL/$PUMIMAGE/ && unzip -o *_1of*.zip
                cd /pumdownload/pumdownloads/PORTAL/$PUMIMAGE/setup
                sh psft-dpk-setup.sh --silent --response_file=$TEMPLATES/portal_response.txt --customization_file=$TEMPLATES/portal_psft_customizations.yaml
        else
                echo "Sorry the PUM Image $PUMIMAGE Not Found for PORTAL"
                exit 5
        fi
elif [ $APPLICATION -eq 5 ]; then
        # ELM execution
                if [ -d /pumdownload/pumdownloads/ELM/$PUMIMAGE ]; then
                cd /pumdownload/pumdownloads/ELM/$PUMIMAGE/ && unzip -o *_1of*.zip
                cd /pumdownload/pumdownloads/ELM/$PUMIMAGE/setup
                sh psft-dpk-setup.sh --silent --response_file=$TEMPLATES/elm_response.txt --customization_file=$TEMPLATES/elm_psft_customizations.yaml
        else
                echo "Sorry the PUM Image $PUMIMAGE Not Found for ELM"
                exit 5
        fi
elif [ $APPLICATION -eq 6 ]; then
        # CS execution

        if [ -d /pumdownload/pumdownloads/CS/$PUMIMAGE ]; then
                cd /pumdownload/pumdownloads/CS/$PUMIMAGE/ && unzip -o *_1of*.zip
                cd /pumdownload/pumdownloads/CS/$PUMIMAGE/setup
                sh psft-dpk-setup.sh --silent --response_file=$TEMPLATES/cs_response.txt --customization_file=$TEMPLATES/cs_psft_customizations.yaml
        else
                echo "Sorry the PUM Image $PUMIMAGE Not Found for CS"
                exit 5
        fi
else
                echo "Wrong Option for the PUM Images"
                exit 1;
fi