Makefile dab template

atuin

Renowned Member
Jun 9, 2009
21
0
66
www.geco-it.fr
Hi,

We use dab to generate a lot of template VM.
So we create a makefile template to minimize preconfigure debian lenny

- replace rsyslog by sysklogd
- replace postfix bu ssmtp
- set locales
- use predefined bash.bashrc
....

Global Makefile: (atuin_template/Systeme_Makefile)

Code:
# Debian Lenny Atuin Minimal Systeme Global Makefile Install

ATUIN_TPMTL_PATH = ../atuin_template
BASEDIR:=$(shell dab basedir)

global: info/init_ok sysinst replacepkg addpkg removepkg config


end:
        #
        #
        # ========================
        # Create OpenVZ Appliance
        # ========================
        dab finalize


info/init_ok: dab.conf
        dab init
        touch $@


sysinst:
        # =======================
        # Sys Install
        #========================
        # Minimal debootstrap
        @dab bootstrap --minimal

        # locales
        @dab install locales
        @sed -e 's/^# fr_FR.UTF-8/fr_FR.UTF-8/' -i ${BASEDIR}/etc/locale.gen
        @sed -e 's/^# fr_FR@euro/fr_FR@euro/' -i ${BASEDIR}/etc/locale.gen
        @dab exec dpkg-reconfigure locales
        # default locale to fr_FR UTF8
        @echo "LANG=fr_FR.UTF-8" > ${BASEDIR}/etc/default/locale

        # Set timezone to Europe/Paris
        @echo "Europe/Paris" > ${BASEDIR}/etc/timezone
        @dab exec rm -f /etc/localtime
        @dab exec cp -f /usr/share/zoneinfo/Europe/Paris /etc/localtime


replacepkg:
        #
        #
        # =======================
        # Replace pkg
        # =======================
        # Replace postfix by ssmtp
        @dab exec aptitude --purge -q remove postfix
        @dab install ssmtp
        #
        #       WARNING : You must edit ssmtp.conf before run make cmd
        #
        @install -m 0644 $(ATUIN_TPMTL_PATH)/ssmtp.conf ${BASEDIR}/etc/ssmtp/ssmtp.conf

        # Replace debconf-i18n by debconf-english
        @wget -q "$(shell fgrep "debconf-english_" ./info/available | grep ^url | cut -d " " -f2)" -O ${BASEDIR}/tmp/debconf-english.deb
        @dab exec dpkg --purge --force-depends debconf-i18n
        @dab exec dpkg -i /tmp/debconf-english.deb

        # replace rsyslog (use ~27Mb of ram) by sysklogd
        @wget -q "$(shell fgrep "/sysklogd_" ./info/available | grep ^url | cut -d " " -f2)" -O ${BASEDIR}/tmp/sysklogd.deb
        @wget -q "$(shell fgrep "/klogd_" ./info/available | grep ^url | cut -d " " -f2)" -O ${BASEDIR}/tmp/klogd.deb
        @dab exec dpkg --purge --force-depends rsyslog
        @dab exec dpkg -i /tmp/sysklogd.deb /tmp/klogd.deb
        @dab exec update-rc.d -f klogd remove

        # remove download pkg
        @rm -f ${BASEDIR}/tmp/*.deb
        #
        #

addpkg:
        #
        #
        # =========================
        # Add pkg
        # =========================
        # Add joe editor
        @dab install joe
        #
        #


removepkg:
        #
        #
        # =====================
        # Remove sys packages
        # =====================
        @dab exec aptitude --purge -q remove tasksel-data tasksel vim-tiny vim-common postfix less nano gcc-4.2-base \
                dmidecode liblocale-gettext-perl libtext-wrapi18n-perl netcat-traditional libtext-charwidth-perl info \
                libtext-iconv-perl libconsole libsasl2-2 python openssl-blacklist ssl-cert python2.5 traceroute
        # don't run ???
        #@dab exec dpkg --purge $(shell chroot ${BASEDIR} dpkg -l | grep ^rc | awk '{print $2}')
        @dab exec dpkg --purge tasksel-data tasksel vim-tiny vim-common postfix less nano gcc-4.2-base \
                dmidecode liblocale-gettext-perl libtext-wrapi18n-perl netcat-traditional libtext-charwidth-perl info \
                libtext-iconv-perl libconsole libsasl2-2 python openssl-blacklist ssl-cert python2.5 traceroute
        #
        #

config:
        #
        #
        # =====================                 
        # Sys Config
        # =====================
        install -m 0644 $(ATUIN_TPMTL_PATH)/profile ${BASEDIR}/etc/profile
        install -m 0644 $(ATUIN_TPMTL_PATH)/bash.bashrc ${BASEDIR}/etc/bash.bashrc
        install -m 0755 $(ATUIN_TPMTL_PATH)/diskclean ${BASEDIR}/usr/sbin/diskclean

        # Network config sample
        install -m 0644 $(ATUIN_TPMTL_PATH)/interfaces.ipfailover ${BASEDIR}/etc/network/interfaces.ipfailover
        install -m 0644 $(ATUIN_TPMTL_PATH)/interfaces.dhcp ${BASEDIR}/etc/network/interfaces.dhcp
        install -m 0644 $(ATUIN_TPMTL_PATH)/interfaces.static ${BASEDIR}/etc/network/interfaces.static

        # Remove start of openssh$
        @dab exec update-rc.d -f ssh remove
        #
        #


.PHONY: clean
clean:
        dab clean
        rm -f *~


.PHONY: dist-clean
dist-clean:
        dab dist-clean
        rm -f *~
Example for minimal debian lenny lamp

Code:
# Include Global Makefile
[B]include ../atuin_template/Systeme_Makefile[/B]

lamp:
        #
        #
        # =====================
        # APACHE + MYSQL + PHP
        # =====================
        # Install Mysql
        @dab task mysql --password random
        # Install Apache 2
        @dab install apache2-mpm-prefork apache2
        # Remove Apache mods
        #dab exec a2dismod alias
        @dab exec a2dismod auth_basic
        @dab exec a2dismod authn_file
        @dab exec a2dismod authz_default
        @dab exec a2dismod authz_groupfile
        @dab exec a2dismod authz_user
        @dab exec a2dismod cgi
        @dab exec a2dismod status
        # Install php5 --memlimit don't run here because we overwrite php.ini file after
        @dab task php
        @dab install php5-mysql

        #                                        
        # php.ini recommended config with memory limit 64M & safe mode on
        @dab exec mv /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.sav
        @dab exec cp /usr/share/doc/php5-common/examples/php.ini-recommended /etc/php5/apache2/php.ini
        #@sed -e 's/^\s*memory_limit\s*=\s*128M/memory_limit = 64M/' -i ${BASEDIR}/etc/php5/apache2/php.ini
        @sed -e 's/^\ssafe_mode\s*=\s*Off/safe_mode = On/' -i ${BASEDIR}/etc/php5/apache2/php.ini
        #
        #


pma:
        #
        #
        # ======================
        # PhpMyAdmin
        # ======================
        #
        @dab install phpmyadmin
        # Config for Apache2 and set Alias /pma for access to phpmyadmin
        @dab exec cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
        @sed -e 's/^Alias \/phpmyadmin/Alias \/pma/' -i ${BASEDIR}/etc/apache2/conf.d/phpmyadmin.conf
        #@dab exec a2enmod alias
        #
        #


all: global lamp pma
        #
        #
        # =======================
        # If no errors reported
        # you can run "make end"
        # to create OpenVZ template
        # =======================
        #
run with make all and if no error run make end to create openvz appliance

I hope this will be useful for other users
Sorry for my bad english
Cyril
 
A fine script indeed!
Zipped up for your convenience with tabs replacing every line's leading spaces, as the normal copy / paste will not work since only leading tab is recognized in the dab / make files.
 

Attachments

  • ATUIN dab Template.zip
    2.5 KB · Views: 32
Last edited:

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!