DAB local variables syntax

apmuthu

Renowned Member
Feb 26, 2009
868
11
83
Chennai - India & Singapore
github.com
How do we declare local variables that are computed from the LXC being built by executing commands in the LXC files under creation?
For example, in Debian 12 Bookworm, we get the PHP Build Date folder name in bash with:
Bash:
PHPBDATE=`ls /usr/lib/php/*/*.so | head -n 1 | cut -d/ -f 5`
 echo ${PHPBDATE}
20220829
mv /root/dbase.so /usr/lib/php/${PHPBDATE}/dbase.so

How is this done in the DAB Makefile using local variables?

The ${BASEDIR} is declared using the shell command at the beginning of the Makefile without the leading tab. How do we do this for within rootfs?

At present we load the files into the root folder in the Makefile and then execute the bash commands in the first boot script like:
Bash:
# Enable dbase module for PHP
PHPBDATE=`ls /usr/lib/php/*/*.so | head -n 1 | cut -d/ -f 5`
PHPVER=`ls /etc/php/*/apache2/php.ini | cut -d/ -f 4`
mv /root/dbase.so /usr/lib/php/${PHPBDATE}/dbase.so
mv /root/dbase.ini /etc/php/${PHPVER}/mods-available/dbase.ini
phpenmod dbase
The above helps not having to install php-dev and building the pecl code and thereby bloating the template and delaying each install by having them in the Makefile as:
Code:
    dab install php-dev
    dab exec pecl install dbase-7.1.1
 
Last edited:
Also what is the best way to auto generate an ssh key in DAB ?

Non interactive ways in the first boot script are:
Bash:
# Using Old Passphrase:
ssh-keygen -q -t rsa -b 4096 -f ~/.ssh/id_rsa -P "" <<<y >/dev/null 2>&1

# Using New Passphrase:
ssh-keygen -q -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" <<<y >/dev/null 2>&1
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!