2018年6月4日星期一

在树莓派上设置PXE服务器,支持从网络启动

在树莓派上安装PXE服务,并使用grub4dos引导系统
参考:
1. https://en.wikipedia.org/wiki/Preboot_Execution_Environment
2. https://github.com/chenall/grub4dos/blob/master/README_GRUB4DOS_CN.txt

一、安装dnsmasq,配置dhcp和tftp服务
sudo apt-get install dnsmasq
修改配置文件/etc/dnsmasq.conf,在文件末尾添加如下内容:
interface=eth0
dhcp-range=192.168.0.2,192.168.0.253,255.255.255.0,12h
enable-tftp
tftp-root=/tftpboot
dhcp-boot=grldr
dhcp-option=3,192.168.0.1

二、配置网卡eth0为静态IP地址
修改/etc/network/interface文件
auto eth0
iface eth0 inet static
        address 192.168.0.1
        netmask 255.255.255.0

三、建立tftpboot文件夹
cd /
sudo mkdir tftpboot
cp grldr /tftpboot
chown -R nobody: /tftpboot

四、设置dnsmasq开机启动
systemctl enable dnsmasq

五、重启系统



2018年4月23日星期一

树莓派常用工具列表

1、反向代理工具:https://github.com/fatedier/frp
frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp, udp, http, https 协议。
利用反向代理和具有公网IP的服务器可以远程访问处于内网的树莓派

2、shadowsocks代理:https://github.com/shadowsocks
A secure socks5 proxy, designed to protect your Internet traffic.


3、代理上网:https://github.com/haad/proxychains
proxychains - a tool that forces any TCP connection made by any given application to follow through proxy like TOR or any other SOCKS4, SOCKS5 or HTTP(S) proxy. Supported auth-types: "user/pass" for SOCKS4/5, "basic" for HTTP.
用法示例:proxychains curl https://www.google.com

4、百度云工具:https://github.com/houtianze/bypy
Python client for Baidu Yun (Personal Cloud Storage) 百度云/百度网盘Python客户端
可以利用bypy在树莓派上访问百度云,首次运行需要授权,授权过程可能需要翻墙才能成功。可以利用shadowsocks和proxychains代理。先安装shadowsocks代理,然后运行:
proxychains bypy info

2017年2月9日星期四

安装配置ubuntu server 16.04

0、背景
旧的笔记本电脑屏幕坏了,准备安装一个linux服务器到电脑上发挥余热。

一、安装
1)下载iso安装文件
2)刻录到空的U盘上,在linux系统中用dd命令直接写入U盘。
3)设置电脑BIOS从U盘启动。
4)安装server,选择英文(中文容易出错)

二、配置记录
2.1 解决合上笔记本盖子自动休眠的问题
修改/etc/systemd/logind.conf文件(注意先备份),命令如下:
cd /etc/systemd
sudo nano logind.conf
去掉HandleLidSwitch签名的注释,并修改值为ignore,如下:
HandleLidSwitch=ignore
保存,然后重启

2.2 配置网络
2.2.1 配置有线网卡
首先获取网卡名称,可用以下命令:
ifconfig -a
得到如eth0/enp0s25等有线网卡名称。
在/etc/network/interfaces中增加以下两行(假定有线网卡名称为eth0)
auto eth0
iface eth0 inet dhcp

2.2.2 配置无线网卡
编辑无线网络配置文件wpa_supplicant.conf
wpa_passphrase  SSID名称  连接用的密码  > /etc/wpa_supplicant.conf
当然,可多个 ssid 配置,后面继续用同样的命令,后跟  >> 追加到配置文件末尾就是。
常用命令:iwconfig,iwlist,wpa_conf

在/etc/network/interfaces中增加以下三行(假定无线网卡名称为wlan0)
auto wlan0
iface wlan0 inet dhcp
wpa_conf /etc/wpa_supplicant.conf

2.3 解决外网访问服务器的问题,设置动态域名解析
申请动态域名解析服务(如http://www.pubyun.com)。
设置路由器进行动态域名解析,或者安装lynx软件在电脑上自动更新IP(参考http://www.pubyun.com/products/dyndns/download/)。
设置路由器端口映射或设置DMZ主机。

2.4 安装phpmyadmin
sudo apt-get install phpmyadmin
访问地址http://服务器IP地址/phpmyadmin

2.5 安装wordpress
参考:https://codex.wordpress.org/zh-cn:%E5%AE%89%E8%A3%85WordPress
在官网下载wordpress安装包
https://cn.wordpress.org/wordpress-4.7.2-zh_CN.tar.gz
将下载的安装包解压到www文件夹
cd /var/www
tar -xzf wordpress.tar.gz
chown -R www-data:www-data /var/www/wordpress
使用phpmyadmin创建数据库和用户
修改主机配置文件
sudo nano /etc/apache2/sites_enabled/000-default.conf
DocumentRoot = /var/www/wordpress

2.6 安装sun java JDK
参考:http://tipsonubuntu.com/2016/07/31/install-oracle-java-8-9-ubuntu-16-04-linux-mint-18/
sudo add-apt-repository ppa:webupd8team/java
sudo apt update; sudo apt install oracle-java8-installer
javac -version
sudo apt install oracle-java8-set-default

2.7 安装opentaps软件(适用于中小企业的CRM+ERP系统)
参考:http://www.opentaps.org/docs/index.php/Opentaps_Installation_Manual

2016年11月3日星期四

安装vpn服务器

https://www.strongswan.org/

strongSwan

the OpenSource IPsec-based VPN Solution

2016年10月9日星期日

在iPhone上使用shadowsocks翻墙

参考资料:https://github.com/shadowsocks/shadowsocks-iOS/wiki/Help
在未越狱的iPhone上使用shadowsocks有两种模式,一种是网页浏览器模式,一种是全局代理模式。以下只讨论全局代理模式,全局代理模式只能在wifi网络下使用。
步骤如下:

  1. 在苹果市场安装shadowsocks软件(需要进入美国市场,软件作者是YumeWorks)
  2. 打开shadowsocks软件,设置代理服务器,代理模式选global)
  3. 设置wifi的http代理,自动代理模式,URL网址填http://127.0.0.1:8090/proxy.pac


2016年9月21日星期三

树莓派GPIO接口图

参考网址:
https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/README.md
http://blog.mangolovecarrot.net/2015/04/20/raspi-study01/
1)物理编号
2)GPIO编号
3)详细说明




用微信控制树莓派

原文网址:http://blog.just4fun.site/pi-wechat.html

2016年9月1日星期四

在树莓派上安装远程桌面服务

1、使用Windows远程桌面服务——Windows Remote Desktop (RDP)
1)安装服务:
sudo apt-get update
sudo apt-get install xrdp
2)查看xrdp服务是否启动
ps ax | grep xrdp

2、使用VNC远程桌面服务——TightVNC
1)安装服务:
sudo apt-get update
sudo apt-get install tightvncserver
2)启动服务
tightvncserver :1

远程控制树莓派(Raspberry Pi)

一、目的
通过互联网远程访问和控制树莓派,不需要固定ip地址,树莓派连接在内网也可以访问。

二、工具
使用weaved工具,官网地址 www.weaved.com

三、步骤
1)在weaved网址注册账号
2)在树莓派上安装weaved工具
参考网址 https://www.weaved.com/installing-weaved-raspberry-pi-raspbian-os/

sudo apt-get update
sudo apt-get install weavedconnectd
sudo weavedinstaller

四、连接树莓派
1)登录weaved网站,选择在树莓派上已经建立的连接服务。
2)使用SSH、WEB等方式登录树莓派。

2015年8月1日星期六

在raspberry pi上安装小度wifi驱动

2016年9月1日更新:最新的raspbian(jessie)系统已经原生支持小度wifi
——————————————————————————————————

一、材料准备

1、raspberry pi 2代
2、小度wifi


二、操作步骤

1、在raspberry pi上安装raspbian系统。

官方镜像下载地址:https://www.raspberrypi.org/downloads/


2、安装gcc4.8

1)添加软件源:
sudo nano /etc/apt/sources.list
在sources.list中添加以下内容
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
# Source repository to add
deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
deb http://archive.raspbian.org/raspbian jessie main contrib non-free rpi
# Source repository to add
deb-src http://archive.raspbian.org/raspbian jessie main contrib non-free rpi


2)新建preferences文件
sudo nano /etc/apt/preferences
添加以下内容
Package: *
Pin: release n=wheezy
Pin-Priority: 900
Package: *
Pin: release n=jessie
Pin-Priority: 300
Package: *
Pin: release o=Raspbian
Pin-Priority: -10


3)更新软件包
sudo apt-get update
4)Install gcc/g++ 4.8 from jessie repositories
sudo apt-get install -t jessie gcc-4.8 g++-4.8


5)Install alternatives
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50


3、用rpi-source软件准备内核编译环境

1)下载rpi-source软件
sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update


2)运行rpi-source
sudo rpi-source


4、编译小度wifi驱动

1)下载源码文件


2)修改源文件
tar xjvf DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2
cd DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/


打开 common/rtusb_dev_id.c,在 {USB_DEVICE(0x148f,0×7601)}, /* MT 6370 */  下面加入以下内容:
{USB_DEVICE(0x148f,0x760b)}, /* 360 Wifi */
{USB_DEVICE(0x2955,0x1001)}, /* baidu Wifi */
{USB_DEVICE(0x2a5f,0x1000)}, /* Tencent WiFi */
{USB_DEVICE(0x2955,0x0001)}, /* XiaoDu Wifi */
{USB_DEVICE(0x2717,0x4106)}, /* Xiaomi Wifi */


打开 include/os/rt_linux.h,找到
int fsuid;
int fsgid;
并把它改为
kuid_t fsuid;
kgid_t fsgid;


3)编译安装
make
make install
modprobe mt7601Usta


5、修改配置文件

修改/etc/network/interfaces文件:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
#allow-hotplug ra0
#iface ra0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf


修改/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
       ssid="yourssid"
       psk="yourpassword"
       proto=RSN
       key_mgmt=WPA-PSK
       pairwise=CCMP TKIP
       group=CCMP TKIP
       auth_alg=OPEN
       priority=3
}


新建/etc/udev/rules.d/95-ralink.rules文件,将无线网卡ra0改为wlan0
nano /etc/udev/rules.d/95-ralink.rules
添加以下内容
ACTION=="add", SUBSYSTEM=="net", ATTR{type}=="1", KERNEL=="ra*", NAME="wlan0"


6、无线路由器模式