#!/bin/sh # Configure cat << EOF > /etc/getinconf-client.conf #!/bin/sh # Automatically generate file with lbmake GTC_SERVER_URL=http://10.139.40.84/index.php NETWORK_NAME=guifi NETWORK_KEY=guifi INTERNAL_DEV=eth0 # POST=665 # GETINCONF_IGNORE=1 EOF # Execute first time. #sed -i -e 's/^exit 0/getinconf-client install\nexit 0/' /etc/rc.local cat > /etc/rc.local << EOF #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. . /etc/getinconf-client.conf DEVICE="\${INTERNAL_DEV}" IP="\$(ip addr show dev \${DEVICE}|grep "inet "|sed 's/.* \([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)\/.*/\1/')" ISSUE="/etc/issue" WAIT_TIME=100 SERF_CRON="/etc/cron.d/serf-reload" UNKNOWN_IP="Unknown" CLOUDYCONF="/etc/cloudy/cloudy.conf" # Remove getinconf-client if \$(dpkg-query -W --showformat='\${Status}\n' getinconf-client |grep -q "install ok installed") then apt-get -y remove getinconf-client fi # Remove cron system if [ -f /etc/cron.d/getinconf-client ] then rm -f /etc/cron.d/getinconf-client fi # Active GETINCONF_IGNORE if [ "\$(cat /etc/getinconf-client.conf|grep -e '^GETINCONF_IGNORE=1\$'|wc -l)" -eq 0 ] then echo "GETINCONF_IGNORE=1" >> /etc/getinconf-client.conf fi if [ ! -f \$SERF_CRON ] then echo "0 * * * * root [ -x /etc/init.d/serf ] && /etc/init.d/serf start > /dev/null 2>&1" > \$SERF_CRON fi cnt=0; while [ -z "\$IP" ] do IP="\$(ip addr show dev \${DEVICE}|grep "inet "|sed 's/.* \([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)\/.*/\1/')"; cnt=\$(expr \$cnt + 1); sleep 1 if [ \$cnt -eq \$WAIT_TIME ] then IP=\$UNKNOWN_IP; fi done if [ "\$IP" != "\$UNKNOWN_IP" ] then /etc/init.d/serf start & fi if \$(fgrep -q "PORT_SSL" \$CLOUDYCONF) then GUIURL="https://\${IP}:7443/" else GUIURL="http://\${IP}:7000/" fi # If ssh keys does not exist make it. if [ ! -f /etc/ssh/ssh_host_dsa_key ] then dpkg-reconfigure openssh-server fi echo 'Debian GNU/Linux '\$(cat /etc/debian_version)' \\\\n \\\\l' > \${ISSUE} echo 'Welcome to' >> \${ISSUE} echo '_________ .__ .___' >> \${ISSUE} echo '\\\\\\\\_ ___ \\\\\\\\| | ____ __ __ __| _/__.__.' >> \${ISSUE} echo '/ \\\\\\\\ \\\\\\\\/| | / _ \\\\\\\\| | \\\\\\\\/ __ < | |' >> \${ISSUE} echo '\\\\\\\\ \\\\\\\\___| |_( <_> ) | / /_/ |\\\\\\\\___ |' >> \${ISSUE} echo ' \\\\\\\\______ /____/\\\\\\\\____/|____/\\\\\\\\____ |/ ____|' >> \${ISSUE} echo ' \\\\\\\\/ \\\\\\\\/\\\\\\\\/ ' >> \${ISSUE} echo "\nPlease open \${GUIURL} with\nyour web browser to configure this server.\n" >> \${ISSUE} exit 0 EOF