Notice me about server's IP address using github
来源:互联网 发布:hyperion数据库重构 编辑:程序博客网 时间:2024/05/17 13:06
1. Problem
The computing machine uses DHCP configuration, and it needs to be shutdown everyday. But I only want to login to it using ssh, rather than the native way. So I need to know its IP address.
2. Analysis
- Autostart script is a good idea.
- It needs to do two things:1. access to Internet; 2. tell me IP address
- sendmail is a good tool. But when I use it, it often fails to send email to me.
- github is an awesome tool.
3. Solution
1.Create a repository and add origin to github. Make sure you can git push without inputting username and password. My native repository is $HOME/.ipaddress
2.Create shell script named updateIP.sh in /etc/init.d/. Here is the content.
#!/bin/bash/etc/init.d/rjsupplicant.shsleep 10wget -q --tries=10 --timeout=20 --spider http://www.baidu.comif [[ $? -eq 0 ]]; then echo "Online" cd $HOME/.ipaddress echo `ifconfig | grep -i "inet addr"` > readme echo `date` >> readme git add . git commit -m "`date`" git push origin masterelse echo "Offline"fi
sudo chmod +x /etc/init.d/updateIP.sh
3.Make it autostart.
sudo vim /etc/xdg/autostart/updateIP.desktop
[Desktop Entry]Type=ApplicationName=updata IP using gitComment=Tell about IP address using githubExec=/etc/init.d/updateIP.shNoDisplay=false
Done.
4. Auto find ip address and use it to login
ip_file="`wget -qO- https://raw.githubusercontent.com/DuinoDu/ipaddress/master/readme`"dl_addr=$(echo $ip_file | grep -i 'inet addr'|cut -d : -f 2 | cut -d ' ' -f 1)echo $dl_addrssh -4CXv cv@$dl_addr
0 0
- Notice me about server's IP address using github
- some tricks about 2s complementary about mask address
- How to set IP address using Qt
- About me!
- About me
- About Me
- About me,
- About me......
- About Me
- About me
- Me.About()
- about me
- About Me
- about me
- About Me
- About me
- About Me
- about me
- 文章标题 POJ 1328 : Radar Installation(贪心)
- android DecorView深入理解
- android 动画基础
- 建立自己的网站
- 自增、自减运算符
- Notice me about server's IP address using github
- Spring MVC中关于重定向的路径问题
- 【算法】直接插入排序
- 【栈】由两个栈组成队列
- xss其他标签下的js用法总结
- c#保留小数点后位数的方法
- 闰年
- break与continue
- 趣味益智