Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tip: A virtual package to do my basic setup
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Wed Feb 29, 2012 12:12 pm    Post subject: Tip: A virtual package to do my basic setup Reply with quote

Motivation:
When I had to install a few gentoo boxes in a row, I was looking for a simple way to install a basic set of packages and came up with this approach, using a virtual package pulling in the packages I wanted.

First approach:
The easiest thing is an ebuild, named virtual/myprefpack-0.ebuild, being a virtual package pulling in my stuff as RDEPEND:
Code:

DESCRIPTION="Virtual for pulling in my default packages"
HOMEPAGE=""
SRC_URI=""

LICENSE=""
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"

DEPEND=""
RDEPEND="
        app-admin/rsyslog
        app-portage/gentoolkit
        app-portage/layman
"


My actual RDEPEND list is bigger than the example listed here, as I want to keep them short for the example.

Adding some jobs and a reminder:
Now as we are lazy, we could perform basic things like updating the mlocate database and remind us of some stuff we shouldn't forget. I did it using einfo/elog messages in pkg_postinst()

Code:

pkg_postinst() {
        einfo "Updating mlocate database...";
        updatedb

        echo -e "\n\n\n"

        elog "********************************************************************"
        elog "Do not forget to:"
        elog "   - add the startup scripts to the runlevels"
        elog "********************************************************************"

}



Introducing USE-Flags for different machine types:
What we did so far was pulling in our packages and running an easy batch job and giving some useful messages. Looking at my systems here, I can sort them into 3 groups: generic clients, generic servers and machines having a the linux/apache/mysql/php stack on them. Introducing USE flags for doing that is pretty simple.

My definition of a pure server machine (USE='server') is, that it's powered on 24/7 while clients are turned off at times, which is why I use vixie-cron there, while using fcron on clients. Servers which are switched off as clients may have both flags set, so I am using a little exclude here:

Code:

DESCRIPTION="Virtual for pulling in my default packages"
HOMEPAGE=""
SRC_URI=""

LICENSE=""
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
IUSE="client lamp server"

DEPEND=""
RDEPEND="
        app-admin/rsyslog
        app-portage/gentoolkit
        app-portage/layman
        client? (
                media-sound/alsa-utils
                net-irc/irssi
                net-misc/keychain
                sys-process/fcron
        )
        lamp? (
                dev-db/phpmyadmin
                dev-lang/php
                www-servers/apache
        )
        server? (
                app-admin/logrotate
                app-misc/screen
                net-misc/ntp
                sys-fs/xfsdump
                sys-fs/xfsprogs
                !client? (
                        sys-process/vixie-cron
                        mail-mta/ssmtp
                        )
                )"



And for our reminder in pkg_postinst(), we can do it that way:
Code:
 elog "   - add the startup scripts to the runlevels"

        if use server ; then
                elog "   - set up ssmtp"
                elog "   - set up rkhunter"
        fi


I am sure there are better ways to do this, but this one seems to be an easy one which worked for me ;)
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
j4miel
n00b
n00b


Joined: 26 Sep 2005
Posts: 54

PostPosted: Wed Feb 29, 2012 2:45 pm    Post subject: Reply with quote

Nice idea, do you manually configure from this point or do you have an easy way to patch configs to your liking?
_________________
I've used the operating system Gentoo
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Wed Feb 29, 2012 2:53 pm    Post subject: Reply with quote

My current config files are fetched from a git repository which could be implemented in pkg_postinstall(), as sandbox isn't interfering there anymore. Sadly this does not honor CONFIG_PROTECT
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Wed Feb 29, 2012 9:43 pm    Post subject: Reply with quote

interesting, thanks. i'd add support for adding required users, setting up services, maybe backups, etc. in theory, could be a nice way to have a simple thing like redhat's kickstart.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8706
Location: ~Brussels - Belgique

PostPosted: Wed Feb 29, 2012 10:01 pm    Post subject: Reply with quote

Nice idea ! 8)

For the moment, I reinstall using something like
Code:
scp workingmachine:/var/lib/portage/wold todo
$EDITOR todo
emerge -av $(cat todo)


Your trick is more scalable and parametrable.
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Thu Mar 01, 2012 7:07 am    Post subject: Reply with quote

avx wrote:
interesting, thanks. i'd add support for adding required users, setting up services, maybe backups, etc. in theory, could be a nice way to have a simple thing like redhat's kickstart.


adding users is possible - even if I would consider that as a waste sometimes:
Code:
enewuser <user> [uid] [shell] [homedir] [groups] [params]


but due to the nature of ebuilds, I wouldn't add service stuff as they can be emerged more than once. Backups could be handled via /etc/cron.daily.
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Thu Mar 01, 2012 10:10 am    Post subject: Reply with quote

Why'd you consider it as a waste? I mean to do it in a dynamic way, ie have some loop-function with a custom variable, so one could do something like
Code:
CREATE_USERS="foo bar baz" emerge my_setup
.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Thu Mar 01, 2012 8:49 pm    Post subject: Reply with quote

Keep in mind that this setup isn't just for 1 box. You don't want to have too many user accounts around. If you are in a bigger network, you might already use LDAP
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
face
n00b
n00b


Joined: 20 Mar 2004
Posts: 12

PostPosted: Sat Mar 10, 2012 10:52 am    Post subject: Reply with quote

puppet could be an alternative to this approach.
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Sat Mar 10, 2012 12:18 pm    Post subject: Reply with quote

but why using additional software?
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
face
n00b
n00b


Joined: 20 Mar 2004
Posts: 12

PostPosted: Mon Mar 12, 2012 7:24 am    Post subject: Reply with quote

convenience ;-)

Its way easier to configure a system with puppet than with portage only. portage is primarily a package manager.
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Mon Mar 12, 2012 8:05 am    Post subject: Reply with quote

Not sure if you got the idea here, as it's about providing a basic install using onboard tools as much as possible. I don't see the need of depending on a greater infrastructure here for 'home use' or 'small business' - sure, your toy might come in handy as soon as the number of machines you have to maintain exceeds 10 boxes...
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
yngwin
Retired Dev
Retired Dev


Joined: 19 Dec 2002
Posts: 4572
Location: Suzhou, China

PostPosted: Mon Mar 12, 2012 11:11 am    Post subject: Reply with quote

This is what sets are for, though I think that requires portage-2.2.
_________________
"Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1191
Location: Austria

PostPosted: Mon Mar 12, 2012 11:36 am    Post subject: Reply with quote

I disagree with that sets would be sufficient for a 'basic setup task' as you cannot add users using sets or performing other scripted tasks like I do using the example.
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum