Benutzer:Drcux: Unterschied zwischen den Versionen

Aus wiki.archlinux.de
Drcux (Diskussion | Beiträge)
Drcux (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
 
(12 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
= Arch Linux als Homeserver =
= pbuild.sh =


<nowiki>
#!/bin/bash


# buildroot
buildroot=/home/pbuild/buildroot


== Grundsystem ==
# break
trap "cleanupandexit" 0 1 2 3 15


=== Installation ===
cleanupandexit()
{
    # save exit code
    rc=$?


Installation gemäß Wiki!
    echo -e $message


Partitionierung:
    # umount /dev & /proc
    if [ $buildroot"x" != "x" ]
        then
            while [ -e $buildroot/proc/uptime ]
                do umount $buildroot/proc
                done
            while [ -e $buildroot/dev/urandom ]
                do umount $buildroot/dev
                done
    fi


* SWAP --> je nach Hauptspeicher
    echo -e "# STOP:\t\t\t" `date`
* /    --> 10GB empfohlen
* /srv --> Restlicher Speicher


Folgende Pakete sind zu installieren:
    exit $rc
}


* base
# start
* arch-install-scripts
echo -e "# START:\t\t" `date`
* bridge-utils
* net-tools
* iproute2


=== Netzwerk konfigurieren ===
# read pkgbuild
if [ -e PKGBUILD ]
    then
        . PKGBUILD
        echo -e "# Package:\t\t" $pkgname
    else
        message="# ERROR:\t\t No PKGBUILD in `pwd`!"
        exit 1
fi


bridge
# delete/create buildroot
echo -e "# Create buildroot:\t" $buildroot


== SSH ==
if [ -d $buildroot ]
    then
        rm -rf $buildroot
fi


== DNS/DHCP ==
# create /dev & /proc
mkdir -p $buildroot/dev
mkdir $buildroot/proc


== Routing/NAT ==
# mount /dev & /proc
mount --bind /dev $buildroot/dev
mount --bind /proc $buildroot/proc


== Proxy ==
# install buildroot
mkdir -p $buildroot/var/lib/pacman
pacman -r $buildroot -Sy
pacman -r $buildroot --noconfirm --noscriptlet --noprogressbar -S base-devel ${makedepends[@]} ${depends[@]}


== NTP ==
# create build user
echo 'build::1000:1000:build:/home/build:/bin/bash' >> $buildroot/etc/passwd
echo 'build::1000:' >>$buildroot/etc/group
mkdir -p $buildroot/home/build
chown -R 1000:1000 $buildroot/home/build


== Active Directory ==
# copy resolv.conf
cp /etc/resolv.conf $buildroot/etc


== Mailserver ==
# copy pkg-files to buildroot
cp -R ./. $buildroot/home/build/


== FTP ==
# build package
chroot $buildroot su -l build -c "cd /home/build; makepkg"


== NFS ==
# build error?
if [ $? -ne 0 ]
    then
        message="# ERROR:\t\t Build failed!"
        exit 1
fi
 
# done
message="# SUCCESS:\t\t Buildjob done!"
 
exit 0
</nowiki>

Aktuelle Version vom 13. Dezember 2017, 19:44 Uhr

pbuild.sh

#!/bin/bash

# buildroot
buildroot=/home/pbuild/buildroot

# break
trap "cleanupandexit" 0 1 2 3 15

cleanupandexit()
{
    # save exit code
    rc=$?

    echo -e $message

    # umount /dev & /proc
    if [ $buildroot"x" != "x" ]
        then
            while [ -e $buildroot/proc/uptime ]
                do umount $buildroot/proc
                done
            while [ -e $buildroot/dev/urandom ]
                do umount $buildroot/dev
                done
    fi

    echo -e "# STOP:\t\t\t" `date`

    exit $rc
}

# start
echo -e "# START:\t\t" `date`

# read pkgbuild
if [ -e PKGBUILD ]
    then
        . PKGBUILD
        echo -e "# Package:\t\t" $pkgname
    else
        message="# ERROR:\t\t No PKGBUILD in `pwd`!"
        exit 1
fi

# delete/create buildroot
echo -e "# Create buildroot:\t" $buildroot

if [ -d $buildroot ]
    then
        rm -rf $buildroot
fi

# create /dev & /proc
mkdir -p $buildroot/dev
mkdir $buildroot/proc

# mount /dev & /proc
mount --bind /dev $buildroot/dev
mount --bind /proc $buildroot/proc

# install buildroot
mkdir -p $buildroot/var/lib/pacman
pacman -r $buildroot -Sy
pacman -r $buildroot --noconfirm --noscriptlet --noprogressbar -S base-devel ${makedepends[@]} ${depends[@]}

# create build user
echo 'build::1000:1000:build:/home/build:/bin/bash' >> $buildroot/etc/passwd
echo 'build::1000:' >>$buildroot/etc/group
mkdir -p $buildroot/home/build
chown -R 1000:1000 $buildroot/home/build

# copy resolv.conf
cp /etc/resolv.conf $buildroot/etc

# copy pkg-files to buildroot
cp -R ./. $buildroot/home/build/

# build package
chroot $buildroot su -l build -c "cd /home/build; makepkg"

# build error?
if [ $? -ne 0 ]
    then
        message="# ERROR:\t\t Build failed!"
        exit 1
fi

# done
message="# SUCCESS:\t\t Buildjob done!"

exit 0