View previous topic :: View next topic |
Author |
Message |
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Wed Feb 29, 2012 12:12 pm Post subject: Tip: A virtual package to do my basic setup |
|
|
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 |
|
|
j4miel n00b
Joined: 26 Sep 2005 Posts: 54
|
Posted: Wed Feb 29, 2012 2:45 pm Post subject: |
|
|
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 |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Wed Feb 29, 2012 2:53 pm Post subject: |
|
|
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 |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Wed Feb 29, 2012 9:43 pm Post subject: |
|
|
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 |
|
|
xaviermiller Bodhisattva
Joined: 23 Jul 2004 Posts: 8706 Location: ~Brussels - Belgique
|
Posted: Wed Feb 29, 2012 10:01 pm Post subject: |
|
|
Nice idea !
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 |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Thu Mar 01, 2012 7:07 am Post subject: |
|
|
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 |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
Posted: Thu Mar 01, 2012 10:10 am Post subject: |
|
|
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 |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Thu Mar 01, 2012 8:49 pm Post subject: |
|
|
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 |
|
|
face n00b
Joined: 20 Mar 2004 Posts: 12
|
Posted: Sat Mar 10, 2012 10:52 am Post subject: |
|
|
puppet could be an alternative to this approach. |
|
Back to top |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Sat Mar 10, 2012 12:18 pm Post subject: |
|
|
but why using additional software? _________________ Please stand by - The mailer daemon is busy burning your messages in hell... |
|
Back to top |
|
|
face n00b
Joined: 20 Mar 2004 Posts: 12
|
Posted: Mon Mar 12, 2012 7:24 am Post subject: |
|
|
convenience
Its way easier to configure a system with puppet than with portage only. portage is primarily a package manager. |
|
Back to top |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Mon Mar 12, 2012 8:05 am Post subject: |
|
|
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 |
|
|
yngwin Retired Dev
Joined: 19 Dec 2002 Posts: 4572 Location: Suzhou, China
|
Posted: Mon Mar 12, 2012 11:11 am Post subject: |
|
|
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 |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Mon Mar 12, 2012 11:36 am Post subject: |
|
|
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 |
|
|
|