Repo Init with files
This commit is contained in:
13
cmd.sh
Executable file
13
cmd.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade -y
|
||||
sudo apt-get -y install dnsmasq
|
||||
sudo apt-get clean
|
||||
sudo chmod +x /usr/local/sbin/usb-gadget.sh
|
||||
sudo systemctl enable usbgadget.service
|
||||
sudo echo dtoverlay=dwc2 >> /boot/config.txt
|
||||
sudo sed -i 's/$/ modules-load=dwc2/' /boot/cmdline.txt
|
||||
sudo echo libcomposite >> /etc/modules
|
||||
sudo systemctl enable getty@ttyGS0.service
|
||||
|
61
etc/dhcpcd.conf
Normal file
61
etc/dhcpcd.conf
Normal file
@@ -0,0 +1,61 @@
|
||||
# A sample configuration for dhcpcd.
|
||||
# See dhcpcd.conf(5) for details.
|
||||
|
||||
# Allow users of this group to interact with dhcpcd via the control socket.
|
||||
#controlgroup wheel
|
||||
|
||||
# Inform the DHCP server of our hostname for DDNS.
|
||||
hostname
|
||||
|
||||
# Use the hardware address of the interface for the Client ID.
|
||||
clientid
|
||||
# or
|
||||
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
|
||||
# Some non-RFC compliant DHCP servers do not reply with this set.
|
||||
# In this case, comment out duid and enable clientid above.
|
||||
#duid
|
||||
|
||||
# Persist interface configuration when dhcpcd exits.
|
||||
persistent
|
||||
|
||||
# Rapid commit support.
|
||||
# Safe to enable by default because it requires the equivalent option set
|
||||
# on the server to actually work.
|
||||
option rapid_commit
|
||||
|
||||
# A list of options to request from the DHCP server.
|
||||
option domain_name_servers, domain_name, domain_search, host_name
|
||||
option classless_static_routes
|
||||
# Respect the network MTU. This is applied to DHCP routes.
|
||||
option interface_mtu
|
||||
|
||||
# Most distributions have NTP support.
|
||||
#option ntp_servers
|
||||
|
||||
# A ServerID is required by RFC2131.
|
||||
require dhcp_server_identifier
|
||||
|
||||
# Generate SLAAC address using the Hardware Address of the interface
|
||||
#slaac hwaddr
|
||||
# OR generate Stable Private IPv6 Addresses based from the DUID
|
||||
slaac private
|
||||
|
||||
# Example static IP configuration:
|
||||
interface usb0
|
||||
static ip_address=10.55.0.1/29
|
||||
nohook wpa_supplicant # don't call the wpa_supplicant hook
|
||||
denyinterfaces usb0 # don't send DHCP requests
|
||||
#static ip6_address=fd51:42f8:caae:d92e::ff/64
|
||||
#static routers=192.168.0.1
|
||||
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
|
||||
|
||||
# It is possible to fall back to a static IP if DHCP fails:
|
||||
# define static profile
|
||||
#profile static_eth0
|
||||
#static ip_address=192.168.1.23/24
|
||||
#static routers=192.168.1.1
|
||||
#static domain_name_servers=192.168.1.1
|
||||
|
||||
# fallback to static profile on eth0
|
||||
#interface eth0
|
||||
#fallback static_eth0
|
7
etc/dnsmasq.conf
Normal file
7
etc/dnsmasq.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
dhcp-authoritative
|
||||
dhcp-rapid-commit
|
||||
no-ping
|
||||
interface=usb0
|
||||
dhcp-range=10.55.0.2,10.55.0.6,255.255.255.248,1h
|
||||
dhcp-option=3,10.55.0.1
|
||||
leasefile-ro
|
4
etc/network/interfaces.d/wlan0
Normal file
4
etc/network/interfaces.d/wlan0
Normal file
@@ -0,0 +1,4 @@
|
||||
auto wlan0
|
||||
allow-hotplug wlan0
|
||||
iface wlan0 inet dhcp
|
||||
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
|
68
etc/sysctl.conf
Normal file
68
etc/sysctl.conf
Normal file
@@ -0,0 +1,68 @@
|
||||
#
|
||||
# /etc/sysctl.conf - Configuration file for setting system variables
|
||||
# See /etc/sysctl.d/ for additional system variables.
|
||||
# See sysctl.conf (5) for information.
|
||||
#
|
||||
|
||||
#kernel.domainname = example.com
|
||||
|
||||
# Uncomment the following to stop low-level messages on console
|
||||
#kernel.printk = 3 4 1 3
|
||||
|
||||
##############################################################3
|
||||
# Functions previously found in netbase
|
||||
#
|
||||
|
||||
# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
|
||||
# Turn on Source Address Verification in all interfaces to
|
||||
# prevent some spoofing attacks
|
||||
#net.ipv4.conf.default.rp_filter=1
|
||||
#net.ipv4.conf.all.rp_filter=1
|
||||
|
||||
# Uncomment the next line to enable TCP/IP SYN cookies
|
||||
# See http://lwn.net/Articles/277146/
|
||||
# Note: This may impact IPv6 TCP sessions too
|
||||
#net.ipv4.tcp_syncookies=1
|
||||
|
||||
# Uncomment the next line to enable packet forwarding for IPv4
|
||||
net.ipv4.ip_forward=1
|
||||
|
||||
# Uncomment the next line to enable packet forwarding for IPv6
|
||||
# Enabling this option disables Stateless Address Autoconfiguration
|
||||
# based on Router Advertisements for this host
|
||||
#net.ipv6.conf.all.forwarding=1
|
||||
|
||||
|
||||
###################################################################
|
||||
# Additional settings - these settings can improve the network
|
||||
# security of the host and prevent against some network attacks
|
||||
# including spoofing attacks and man in the middle attacks through
|
||||
# redirection. Some network environments, however, require that these
|
||||
# settings are disabled so review and enable them as needed.
|
||||
#
|
||||
# Do not accept ICMP redirects (prevent MITM attacks)
|
||||
#net.ipv4.conf.all.accept_redirects = 0
|
||||
#net.ipv6.conf.all.accept_redirects = 0
|
||||
# _or_
|
||||
# Accept ICMP redirects only for gateways listed in our default
|
||||
# gateway list (enabled by default)
|
||||
# net.ipv4.conf.all.secure_redirects = 1
|
||||
#
|
||||
# Do not send ICMP redirects (we are not a router)
|
||||
#net.ipv4.conf.all.send_redirects = 0
|
||||
#
|
||||
# Do not accept IP source route packets (we are not a router)
|
||||
#net.ipv4.conf.all.accept_source_route = 0
|
||||
#net.ipv6.conf.all.accept_source_route = 0
|
||||
#
|
||||
# Log Martian Packets
|
||||
#net.ipv4.conf.all.log_martians = 1
|
||||
#
|
||||
|
||||
###################################################################
|
||||
# Magic system request Key
|
||||
# 0=disable, 1=enable all, >1 bitmask of sysrq functions
|
||||
# See https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html
|
||||
# for what other values do
|
||||
#kernel.sysrq=438
|
||||
|
9
etc/wpa_supplicant/wpa_supplicant.conf
Normal file
9
etc/wpa_supplicant/wpa_supplicant.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
|
||||
update_config=1
|
||||
|
||||
country=FR
|
||||
network={
|
||||
ssid="<YOUR-SSID>"
|
||||
psk="<YOUR-PASSPHRASE>"
|
||||
key_mgmt=WPA-PSK
|
||||
}
|
13
lib/systemd/system/usbgadget.service
Normal file
13
lib/systemd/system/usbgadget.service
Normal file
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=My USB gadget
|
||||
After=systemd-modules-load.service network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/local/sbin/usb-gadget.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
||||
|
58
usr/local/sbin/usb-gadget.sh
Executable file
58
usr/local/sbin/usb-gadget.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
GADGET=/sys/kernel/config/usb_gadget/display-pi
|
||||
|
||||
SERIAL=`cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2`
|
||||
if [ -n "$SERIAL" ]; then
|
||||
MAC="fa:${SERIAL:6:2}:${SERIAL:8:2}:${SERIAL:10:2}:${SERIAL:12:2}:${SERIAL:14:2}"
|
||||
else
|
||||
MAC="fa:31:43:14:31:43"
|
||||
fi
|
||||
|
||||
mount -t configfs none /sys/kernel/config
|
||||
mkdir -p $GADGET
|
||||
cd $GADGET
|
||||
|
||||
echo 0x1d6b > idVendor # Linux Foundation
|
||||
echo 0x0104 > idProduct # Multifunction Composite Gadget
|
||||
echo 0x0100 > bcdDevice # v1.0.0
|
||||
echo 0x0200 > bcdUSB # USB2
|
||||
|
||||
echo 0xEF > bDeviceClass
|
||||
echo 0x02 > bDeviceSubClass
|
||||
echo 0x01 > bDeviceProtocol
|
||||
|
||||
mkdir strings/0x409
|
||||
echo $SERIAL > strings/0x409/serialnumber
|
||||
echo "Raspberry Pi" > strings/0x409/manufacturer
|
||||
echo "Display-Pi USB Device" > strings/0x409/product
|
||||
|
||||
mkdir -p functions/acm.usb0 # serial
|
||||
mkdir -p functions/rndis.usb0 # network
|
||||
#mkdir -p functions/ecm.usb0
|
||||
#echo $MAC > functions/ecm.usb0/dev_addr
|
||||
|
||||
mkdir -p configs/c.1
|
||||
echo 250 > configs/c.1/MaxPower
|
||||
ln -s functions/rndis.usb0 configs/c.1/
|
||||
ln -s functions/acm.usb0 configs/c.1/
|
||||
#ln -s functions/ecm.usb0 configs/c.1/
|
||||
|
||||
# OS descriptors
|
||||
# echo 1 > os_desc/use
|
||||
# echo 0xcd > os_desc/b_vendor_code
|
||||
# echo MSFT100 > os_desc/qw_sign
|
||||
#
|
||||
# echo RNDIS > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
|
||||
# echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
|
||||
#
|
||||
# ln -s configs/c.1 os_desc
|
||||
|
||||
# Assuming there is only ever going to be one UDC
|
||||
udevadm settle -t 5 || :
|
||||
ls /sys/class/udc > UDC
|
||||
|
||||
# systemctl restart networking
|
||||
# systemctl restart dnsmasq
|
||||
# systemctl restart sshd
|
||||
|
Reference in New Issue
Block a user