<commit_before>MAJ=5                    # Version major number
MIN=3                    # Version minor number
ARCH=$(uname -p)         # Architecture
TZ=UTC                   # Time zones are in /usr/share/zoneinfo

BASEURL=ftp://ftp3.usa.openbsd.org/pub/OpenBSD
MIRROR=$BASEURL/$MAJ.$MIN/$ARCH
PKG_PATH=$BASEURL/$MAJ.$MIN/packages/$ARCH

APPLIANCE_SCRIPT_DIR='/vagrant/akanda-appliance/scripts'

# Additional packages that should be installed on the akanda live cd
PACKAGES="ntp python-2.7.3p1 py-pip wget dnsmasq bird-v6-1.3.9p0"

DNS=8.8.8.8

echo "[*] Creating motd file..."
cat >/etc/motd <<EOF
    ___   ___                       .___
   /   \\  \\  | - L3 for OpenStack - | _/
  /  _  \\ |  | _______    ____    __| | ____
 /  /_\\  \\|  |/ /\\__  \\  /    \\  / __ |\\__  \\
/    |    \\    <  / __ \\|   |  \\/ /_/ | / __ \\_
\\____|__  /__|_ \\(____  /___|  /\\____ |(____  /
        \\/     \\/     \\/     \\/      \\/     \\/
Welcome to Akanda: Powered by OpenBSD.


EOF

echo "[*] Setting name..."
cat > /etc/myname <<EOF
akanda
EOF

echo "[*] Modifying the library path..."
cat > /root/.cshrc << EOF
# Workaround for missing libraries:
export LD_LIBRARY_PATH=/usr/local/lib
EOF

echo "[*] Using DNS ($DNS) in livecd environment..."
echo "nameserver $DNS" > /etc/resolv.conf

echo "[*] Disabling services...."
cat > /etc/rc.conf.local <<EOF
spamlogd_flags=NO
inetd=NO
amd_master=NO
EOF

echo "[*] Installing additional packages..."
cat > /tmp/packages.sh <<EOF
#!/bin/sh -e
export PKG_PATH=$(echo $PKG_PATH | sed 's#\ ##g')
for i in $PACKAGES
do
   pkg_add -i \$i
done
EOF

chmod +x /tmp/packages.sh
/tmp/packages.sh || exit 1
rm /tmp/packages.sh

mkdir /etc/dnsmasq.d
cat > /etc/dnsmasq.conf <<EOF
bind-interfaces
leasefile-ro
domain-needed
bogus-priv
no-hosts
no-poll
strict-order
dhcp-lease-max=256
conf-dir=/etc/dnsmasq.d
EOF

echo "[*] Installing akanda software..."
cat > /tmp/akanda.sh <<EOF
#!/bin/sh -e
export LD_LIBRARY_PATH=/usr/local/lib

ln -sf /usr/local/bin/python2.7 /usr/local/bin/python
ln -sf /usr/local/bin/pip-2.7 /usr/local/bin/pip

cd /root/src/greenlet-0.4.0
python setup.py install

cd /root/src/eventlet-0.12.1
python setup.py install

cd /vagrant/akanda-appliance
python setup.py install
EOF

mkdir -p /root/src
cd /root/src

tar -zxf $APPLIANCE_SCRIPT_DIR/src/greenlet-0.4.0.tar.gz
tar -zxf $APPLIANCE_SCRIPT_DIR/src/eventlet-0.12.1.tar.gz

cd /root

chmod +x /tmp/akanda.sh
/tmp/akanda.sh || exit 1
rm /tmp/akanda.sh

rm -rf /root/src

echo "[*] Add rc.d scripts...."
cp $APPLIANCE_SCRIPT_DIR/etc/rc.d/sshd /etc/rc.d/sshd
cp $APPLIANCE_SCRIPT_DIR/etc/rc.d/metadata /etc/rc.d/metadata
chmod 555 /etc/rc.d/sshd
chmod 555 /etc/rc.d/metadata

echo "[*] Add some stuff to sysctl.conf"
cat > $WDIR/etc/sysctl.conf <<EOF
net.inet6.ip6.dad_count=0
EOF

echo "[*] Add rc.local file...."
cp $APPLIANCE_SCRIPT_DIR/etc/rc.local /etc/rc.local
<commit_msg>Install depends using pip - Use pip to install eventlet/greenlet - APPLIANCE_BASE_DIR default to /root/akanda-applaince - /root/src no longer needed<commit_after>MAJ=5                    # Version major number
MIN=3                    # Version minor number
ARCH=$(uname -p)         # Architecture
TZ=UTC                   # Time zones are in /usr/share/zoneinfo

BASEURL=ftp://ftp3.usa.openbsd.org/pub/OpenBSD
MIRROR=$BASEURL/$MAJ.$MIN/$ARCH
PKG_PATH=$BASEURL/$MAJ.$MIN/packages/$ARCH
APPLIANCE_BASE_DIR="/root/akanda-appliance"
APPLIANCE_SCRIPT_DIR="$APPLIANCE_BASE_DIR/scripts"

# Additional packages that should be installed on the akanda live cd
PACKAGES="ntp python-2.7.3p1 py-pip wget dnsmasq bird-v6-1.3.9p0"

DNS=8.8.8.8

echo "[*] Creating motd file..."
cat >/etc/motd <<EOF
    ___   ___                       .___
   /   \\  \\  | - L3 for OpenStack - | _/
  /  _  \\ |  | _______    ____    __| | ____
 /  /_\\  \\|  |/ /\\__  \\  /    \\  / __ |\\__  \\
/    |    \\    <  / __ \\|   |  \\/ /_/ | / __ \\_
\\____|__  /__|_ \\(____  /___|  /\\____ |(____  /
        \\/     \\/     \\/     \\/      \\/     \\/
Welcome to Akanda: Powered by OpenBSD.


EOF

echo "[*] Setting name..."
cat > /etc/myname <<EOF
akanda
EOF

echo "[*] Modifying the library path..."
cat > /root/.cshrc << EOF
# Workaround for missing libraries:
export LD_LIBRARY_PATH=/usr/local/lib
EOF

echo "[*] Using DNS ($DNS) in livecd environment..."
echo "nameserver $DNS" > /etc/resolv.conf

echo "[*] Disabling services...."
cat > /etc/rc.conf.local <<EOF
spamlogd_flags=NO
inetd=NO
amd_master=NO
EOF

echo "[*] Installing additional packages..."
cat > /tmp/packages.sh <<EOF
#!/bin/sh -e
export PKG_PATH=$(echo $PKG_PATH | sed 's#\ ##g')
for i in $PACKAGES
do
   pkg_add -i \$i
done
EOF

chmod +x /tmp/packages.sh
/tmp/packages.sh || exit 1
rm /tmp/packages.sh

mkdir /etc/dnsmasq.d
cat > /etc/dnsmasq.conf <<EOF
bind-interfaces
leasefile-ro
domain-needed
bogus-priv
no-hosts
no-poll
strict-order
dhcp-lease-max=256
conf-dir=/etc/dnsmasq.d
EOF

echo "[*] Installing akanda software..."
cat > /tmp/akanda.sh <<EOF
#!/bin/sh -e
export LD_LIBRARY_PATH=/usr/local/lib

ln -sf /usr/local/bin/python2.7 /usr/local/bin/python
ln -sf /usr/local/bin/pip-2.7 /usr/local/bin/pip

pip install greenlet==0.4.0
pip install eventlet==0.12.1

cd $APPLIANCE_BASE_DIR
python setup.py install
EOF

cd /root

chmod +x /tmp/akanda.sh
/tmp/akanda.sh || exit 1
rm /tmp/akanda.sh

echo "[*] Add rc.d scripts...."
cp $APPLIANCE_SCRIPT_DIR/etc/rc.d/sshd /etc/rc.d/sshd
cp $APPLIANCE_SCRIPT_DIR/etc/rc.d/metadata /etc/rc.d/metadata
chmod 555 /etc/rc.d/sshd
chmod 555 /etc/rc.d/metadata

echo "[*] Add some stuff to sysctl.conf"
cat > $WDIR/etc/sysctl.conf <<EOF
net.inet6.ip6.dad_count=0
EOF

echo "[*] Add rc.local file...."
cp $APPLIANCE_SCRIPT_DIR/etc/rc.local /etc/rc.local

{'fraction_non_alphanumeric': 0.16689968542467667, 'fraction_numerical': 0.015903530234183852, 'mean_word_length': 2.4726941747572817, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7300955', 'n_tokens_mistral': 2431, 'n_tokens_neox': 2303, 'n_words': 481}