Bit of an odd one, so bear with me.
I am building an Azure VM image using Packer. Part of the install requires some Python libraries to be installed. I can execute this via a Shell script in the Packer run list, however when the image is sealed and ready to be used those libraries are not installed.
I have found that the libraries aren't installed because it's installed to a user profile, and part of the Packer process is to delete said user profile upon 'resealing' the image for use.
I have Googled a number of ways, but I have't found anything that allows me to run as script on login for a user that doesn't exist yet, as when we first use the image and log in, the account is created.
Does anyone know how I could run this script on logon on first use?
#!/bin/bash
cd /
echo "Testing to make sure that script performed as expected, and basic scenarios work"
for cmd in python pip; do
if ! command -v $cmd; then
echo "$cmd was not installed or not found on PATH"
exit 1
fi
done
list1=(
pandevice
pan-python
requests
requests_toolbelt
requests[security]
)
for i in "${list1[@]}"; do
pip install $i
done
list2=(
asn1crypto
certifi
cffi
chardet
cryptography
enum34
idna
ipaddress
pan-python
pandevice
pycparser
pyOpenSSL
requests
requests-toolbelt
six
urllib3
)
for x in "${list2[@]}"; do
if ! pip freeze | grep $x; then
echo "$x was not installed or not found on PATH"
exit 1
fi
done
Just so you know, I have thought about using sudo pip install, however; What are the risks of running 'sudo pip'?