Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Saturday, December 26, 2015

Hotspot script for ubuntu

This script was tested on both Ubuntu 12.04


#!/bin/sh
# 20141208
# hotspot access point creation for android mobiles in ubuntu 12.04.4; works for laptop to laptop connection as well

zenity --warning --text "Run this script from terminal. \n ./hotspot_install. \n Close dialog box/ESC if you are running via terminal. Else click ok/ENTER."
if [ $? -eq 0 ]
then
    exit
fi

echo "Is ap-hotspot already installed (y/n) ? "
read ch
if [ "$ch" = "n" ]
then
    sudo add-apt-repository ppa:nilarimogard/webupd8
    sudo apt-get update
    sudo apt-get install ap-hotspot
fi


echo "Is ap-hotspot already configured (y/n) ? "
read ch
if [ "$ch" = "n" ]
then
    echo "configure your hotspot. give an access point name and good password"
    sudo ap-hotspot configure
    echo "delete all hotspot connection. Disconnect connected hotspots. Then Network -> Wireless -> Forget/Remove all hotspot. Then press any key to continue..."
    read key
fi

sudo ap-hotspot start

echo "Are you able to obtain ip address in your android mobile (y/n) ? "
read ch
if [ "$ch" = "n" ]
then
    echo "configuring network manager"
    sudo sed -i 's:^dns=dnsmasq:#dns=dnsmasq:gi' /etc/NetworkManager/NetworkManager.conf
    echo "restarting network manager"
    sudo service network-manager restart
    echo "check if following command does not say nameserver 127.0.0.1"
    cat /etc/resolv.conf
    echo "restarting ap-hotspot"
    sudo ap-hotspot stop
    sudo ap-hotspot start
fi