https://wiki.znc.in/index.php?title=Chroot/Script&feed=atom&action=history
Chroot/Script - Revision history
2024-03-29T05:40:01Z
Revision history for this page on the wiki
MediaWiki 1.42.0-alpha
https://wiki.znc.in/index.php?title=Chroot/Script&diff=274&oldid=prev
KindOne: Update URL.
2014-09-30T16:35:53Z
<p>Update URL.</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 16:35, 30 September 2014</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l7">Line 7:</td>
<td colspan="2" class="diff-lineno">Line 7:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # The source .tar.gz that is installed for chrooting</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # The source .tar.gz that is installed for chrooting</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> SOURCE="http://znc.in/nightly/znc<del style="font-weight: bold; text-decoration: none;">-svn</del>-latest.tar.gz"</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> SOURCE="http://znc.in/nightly/znc-latest.tar.gz"</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # The chroot used</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # The chroot used</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> CHROOT="/var/chroot/znc"</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> CHROOT="/var/chroot/znc"</div></td></tr>
</table>
KindOne
https://wiki.znc.in/index.php?title=Chroot/Script&diff=273&oldid=prev
DarthGandalf: Created page with "{{ambox|type=serious|text= Running ZNC in a chrooted environment is unsupported. Either you know what you are doing, or you don't do it! }} This script will download the lates..."
2011-12-17T11:01:25Z
<p>Created page with "{{ambox|type=serious|text= Running ZNC in a chrooted environment is unsupported. Either you know what you are doing, or you don't do it! }} This script will download the lates..."</p>
<p><b>New page</b></p><div>{{ambox|type=serious|text=<br />
Running ZNC in a chrooted environment is unsupported. Either you know what you are doing, or you don't do it!<br />
}}<br />
This script will download the latest ZNC snapshot and install it so that it can be used for running a chrooted ZNC. Read the comments in the beginning of the script to learn more.<br />
<br />
#!/bin/bash<br />
<br />
# The source .tar.gz that is installed for chrooting<br />
SOURCE="http://znc.in/nightly/znc-svn-latest.tar.gz"<br />
# The chroot used<br />
CHROOT="/var/chroot/znc"<br />
# The user for running ZNC<br />
USER="znc"<br />
# Arguments to configure (like --disable-shit etc)<br />
CONFIGURE_ARGS=""<br />
# Arguments to make<br />
MAKE_ARGS="-j3"<br />
<br />
# Don't change stuff after here<br />
<br />
if <nowiki>[[ $UID == 0 ]]</nowiki><br />
then<br />
echo "You don't need to (and shouldn't) run this file as root!"<br />
exit<br />
fi<br />
<br />
DL="dl-znc.tar.gz"<br />
TMPDIR=$(mktemp -d)<br />
# Automatically clean up<br />
trap 'rm -rf $TMPDIR' EXIT INT HUP QUIT TERM<br />
<br />
cd $TMPDIR<br />
<br />
log()<br />
{<br />
echo<br />
tput smso<br />
echo $@<br />
tput rmso<br />
}<br />
<br />
log Downloading...<br />
wget -O $TMPDIR/$DL $SOURCE || exit<br />
<br />
log Extracting...<br />
tar -xzf $DL || exit<br />
<br />
# We assume this extracts to znc*<br />
cd znc* || exit<br />
<br />
log Configuring...<br />
./configure $CONFIGURE_ARGS --prefix=/usr || exit<br />
<br />
log Compiling...<br />
make $MAKE_ARGS || exit<br />
<br />
log Installing to ${CHROOT}...<br />
make install DESTDIR=${CHROOT} || exit<br />
<br />
mkdir -p $CHROOT/etc<br />
mkdir -p $CHROOT/lib<br />
mkdir -p $CHROOT/usr/lib<br />
mkdir -p $CHROOT/dev<br />
mkdir -p $CHROOT/home<br />
mkdir -p $CHROOT/home/$USER<br />
<br />
log "Copying needed libs... (All are saved in ${CHROOT}/usr/lib)"<br />
cd $CHROOT<br />
ldd $CHROOT/usr/bin/znc |<br />
sed -e 's/[ \t]*//g' -e 's/^.*=>//' -e 's/(.*)$//' |<br />
while read file<br />
do<br />
if <nowiki>[[ $file == '' ]]</nowiki><br />
then<br />
continue<br />
fi<br />
<br />
if <nowiki>[[ -f $CHROOT/$file ]]</nowiki><br />
then<br />
rm $CHROOT/$file<br />
fi<br />
<br />
echo "Copying ${file}..."<br />
dir=$(echo $file | sed 's:/[^/]*$::')<br />
f=$(echo $file | sed 's:^.*/::')<br />
mkdir -p ${CHROOT}/$dir<br />
cp -p $file $CHROOT/lib/$f<br />
done<br />
<br />
log "Symlinking /usr/lib64 to /usr/lib... (just in case ;)"<br />
ln -s lib $CHROOT/usr/lib64<br />
<br />
log Trying to copy files needed for DNS...<br />
cp -p /etc/hosts $CHROOT/etc/<br />
cp -p /etc/resolv.conf $CHROOT/etc/<br />
cp -p /lib/libnss_dns.so.2 $CHROOT/lib \<br />
|| log Copying libnss_dns.so.2 failed, DNS may be broken!<br />
cp -p /lib/libresolv.so.2 $CHROOT/lib \<br />
|| log Copying libresolv.so.2 failed, DNS may be broken!<br />
<br />
cat <<OUT<br />
<br />
Done<br />
<br />
You should now su to root.<br />
<br />
There are some files in the chroot which need to be created by root:<br />
(This assumes you are using linux, good luck for other OS)<br />
mknod -m 644 ${CHROOT}/dev/random c 1 8<br />
mknod -m 644 ${CHROOT}/dev/urandom c 1 9<br />
mknod -m 666 ${CHROOT}/dev/null c 1 3<br />
<br />
You need a user and a group which will be used to run ZNC:<br />
useradd --user-group --home-dir=/home/$USER $USER<br />
chown -R $USER:$USER ${CHROOT}<br />
<br />
After this, you should be able to start ZNC.<br />
<br />
To start up ZNC for creating a configuration, run this:<br />
su $USER -- -c '${CHROOT}/usr/bin/znc --makeconf --datadir ${CHROOT}/home/$USER/.znc'<br />
<br />
To start and stop use these commands:<br />
start-stop-daemon --chroot ${CHROOT} --chuid $USER:$USER --start --exec /usr/bin/znc<br />
start-stop-daemon --chroot ${CHROOT} --chuid $USER:$USER --stop --exec /usr/bin/znc<br />
OUT</div>
DarthGandalf