Running servers in crouton - andrewscaya/crouton GitHub Wiki
If you plan to run a server within crouton, you'll need the following:
- Install the iptables package,
sudo apt-get install iptables
- Add a line to
/etc/rc.local
to launch the service you want. Examples for different services are given below. - Add a line to
/etc/rc.local
to open the firewall, for example:-
/sbin/iptables -P INPUT ACCEPT
to accept all inbound traffic. Or, -
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
to accept a specific port, e.g.22
for the SSH example.
-
This will start the server when the chroot is started, not when ChromeOS is booting. To auto-start the chroot on ChromeOS boot, see these instructions.
Add the following to /etc/rc.local to enable ssh into your chroot. Tested in Ubuntu 13.10. Previously /etc/init.d/ssh start was all that was needed. Works well with Secure Shell Chrome app.
On Jessie and Sid only the iptables rule is needed. sudo system ssh start
will work to start the server.
mkdir -p -m0755 /var/run/sshd
/usr/sbin/sshd
- Install the avahi-daemon, avahi-utils and libnss-mdns packages,
sudo apt-get install avahi-daemon avahi-utils libnss-mdns
- In the /etc/avahi/avahi-daemon.conf file, uncomment the
#host-name=foo
record and set the host-name you desire, for examplehostname=mychromebook
. - Add the following to /etc/rc.local to enable avahi in your chroot. Tested in Ubuntu 12.04. Do not run avahi-daemon as a daemon (-D option). Doing so will cause it to miss the configuration parameters in /etc/avahi and fail.
/usr/sbin/avahi-daemon --syslog &
Optionally, if you are running an OpenSSH or apache server, add corresponding service files to the /etc/avahi/services directory in order to publicize the service on the local network. An example for OpenSSH:
cat /etc/avahi/services/ssh.service
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_ssh._tcp</type>
<port>22</port>
</service>
</service-group>
A quick test of the service is to ping a known local resource: ping myhomelanserver.local
. The the local name should resolve to the server IP address.
You'll need to start Apache and MySQL on your rc.local
- nano /etc/rc.local
- Paste this using shift+ctrl+v, save with ctrl+x
/etc/init.d/apache2 start
export HOME=/etc/mysql
umask 007
[ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld
/usr/sbin/mysqld &
- save with ctrl+x