Skip to content

Instantly share code, notes, and snippets.

@hpsaturn
Last active August 30, 2016 19:51
Show Gist options
  • Save hpsaturn/68d26c07b66dcab56ec4f842b3fc4fa8 to your computer and use it in GitHub Desktop.
Save hpsaturn/68d26c07b66dcab56ec4f842b3fc4fa8 to your computer and use it in GitHub Desktop.
#!/bin/sh
###################################################################
# Load hotspot
# 2009-2010 Hpsaturn v1.0
# [email protected]
#
# REV000: Creación de funciones iniciales. Mode Ad-Hoc soportado
###################################################################
DEVICE=wlan0
MODULE=iwldvm
start_spot () {
remove_module
sleep 1
install_module
ifconfig $DEVICE down
sleep 1
echo -n "set static gateway.."
ifconfig $DEVICE 192.168.2.1 netmask 255.255.255.0
ifconfig $DEVICE up
echo "ok"
echo "start hostapd:"
service hostapd start
echo "start NAT:"
#/etc/init.d/load_iptables restart
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -d 0.0.0.0/0 -j MASQUERADE
echo "start dnsmask:"
service dnsmasq restart
}
stop_spot () {
stop_services
# TODO: loader..
}
stop_services () {
msg="stop_services"
ifconfig $DEVICE down
service hostapd stop
service dnsmasq stop
pidstop=$!
}
remove_module () {
echo -n "remove modules.."
modprobe -rv $MODULE
echo "done."
}
install_module () {
echo -n "install modules.."
modprobe $MODULE
echo "done."
}
case "$1" in
start)
start_spot
;;
stop)
stop_spot
;;
restart)
stop_spot
start_spot
;;
*)
echo "Usage: load_hotspot {start|stop|restart}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment