mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 20:20:06 +09:00
Initial commit
This commit is contained in:
commit
e45b6d421f
26
LICENSE
Normal file
26
LICENSE
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
raspi-config is licensed under the terms of the MIT license reproduced below.
|
||||||
|
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
Copyright (c) 2012 Alex Bradbury <asb@asbradbury.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
raspi-config (20120610) unstable; urgency=low
|
||||||
|
|
||||||
|
* Initial release
|
||||||
|
|
||||||
|
-- Alex Bradbury <asb@asbradbury.org> Sun, 10 Jun 2012 15:59:17 +0000
|
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
8
|
14
debian/control
vendored
Normal file
14
debian/control
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Source: raspi-config
|
||||||
|
Section: unknown
|
||||||
|
Priority: extra
|
||||||
|
Maintainer: Alex Bradbury <asb@asbradbury.org>
|
||||||
|
Build-Depends: debhelper (>= 8.0.0)
|
||||||
|
Standards-Version: 3.9.2
|
||||||
|
Homepage: https://github.com/asb/raspi-config
|
||||||
|
#Vcs-Git: git://git.debian.org/collab-maint/raspi-config.git
|
||||||
|
#Vcs-Browser: http://git.debian.org/?p=collab-maint/raspi-config.git;a=summary
|
||||||
|
|
||||||
|
Package: raspi-config
|
||||||
|
Architecture: all
|
||||||
|
Depends: ${misc:Depends}, whiptail, parted
|
||||||
|
Description: Simple configuration for Raspberry Pi
|
2
debian/raspi-config.docs
vendored
Normal file
2
debian/raspi-config.docs
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
LICENSE
|
||||||
|
sample_profile_d.sh
|
1
debian/raspi-config.install
vendored
Normal file
1
debian/raspi-config.install
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
./raspi-config /usr/bin/
|
13
debian/rules
vendored
Executable file
13
debian/rules
vendored
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
# -*- makefile -*-
|
||||||
|
# Sample debian/rules that uses debhelper.
|
||||||
|
# This file was originally written by Joey Hess and Craig Small.
|
||||||
|
# As a special exception, when this file is copied by dh-make into a
|
||||||
|
# dh-make output file, you may use that output file without restriction.
|
||||||
|
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||||
|
|
||||||
|
# Uncomment this to turn on verbose mode.
|
||||||
|
#export DH_VERBOSE=1
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
187
raspi-config
Executable file
187
raspi-config
Executable file
@ -0,0 +1,187 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Part of raspi-config http://github.com/asb/raspi-config
|
||||||
|
#
|
||||||
|
# See LICENSE file for copyright and license details
|
||||||
|
|
||||||
|
|
||||||
|
if [ $(id -u) -ne 0 ]; then
|
||||||
|
printf "Script must be run as root\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
do_info() {
|
||||||
|
whiptail --msgbox "This tool provides a straight-forward way of doing
|
||||||
|
initial configuration of the Raspberry Pi. Although it can be run at any
|
||||||
|
time, some of the options may have difficulties if you have heavily
|
||||||
|
customised your installation." 20 60 1
|
||||||
|
}
|
||||||
|
|
||||||
|
do_expand_rootfs() {
|
||||||
|
# Get the starting offset of the root partition
|
||||||
|
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^2" | cut -f 2 -d:)
|
||||||
|
[ "$PART_START" ] || return 1
|
||||||
|
# Return value will likely be error for fdisk as it fails to reload the
|
||||||
|
# partition table because the root fs is mounted
|
||||||
|
fdisk /dev/mmcblk0 <<EOF
|
||||||
|
p
|
||||||
|
d
|
||||||
|
2
|
||||||
|
n
|
||||||
|
p
|
||||||
|
2
|
||||||
|
$PART_START
|
||||||
|
|
||||||
|
p
|
||||||
|
w
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# now set up an init.d script
|
||||||
|
cat <<\EOF > /etc/init.d/resize2fs_once &&
|
||||||
|
#!/bin/sh
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: resize2fs_once
|
||||||
|
# Required-Start:
|
||||||
|
# Required-Stop:
|
||||||
|
# Default-Start: 2 3 4 5 S
|
||||||
|
# Default-Stop:
|
||||||
|
# Short-Description: Resize the root filesystem to fill partition
|
||||||
|
# Description:
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
log_daemon_msg "Starting resize2fs_once" &&
|
||||||
|
resize2fs /dev/mmcblk0p2 &&
|
||||||
|
rm /etc/init.d/resize2fs_once &&
|
||||||
|
update-rc.d resize2fs_once remove &&
|
||||||
|
log_end_msg $?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 start" >&2
|
||||||
|
exit 3
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
EOF
|
||||||
|
chmod +x /etc/init.d/resize2fs_once &&
|
||||||
|
update-rc.d resize2fs_once defaults &&
|
||||||
|
whiptail --msgbox "Root partition has been resized.\n\
|
||||||
|
The filesystem will be enlarged upon the next reboot" 20 60 2
|
||||||
|
}
|
||||||
|
|
||||||
|
# $1 is 0 to disable overscan, 1 to disable it
|
||||||
|
set_overscan() {
|
||||||
|
# Stop if /boot is not a mountpoint
|
||||||
|
if ! mountpoint -q /boot; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -e /boot/config.txt ] || touch /boot/config.txt
|
||||||
|
|
||||||
|
if [ "$1" -eq 0 ]; then # disable overscan
|
||||||
|
sed /boot/config.txt -i -e "s/^overscan_/#overscan_/"
|
||||||
|
if grep -q "^disable_overscan" /boot/config.txt; then
|
||||||
|
sed -i /boot/config.txt -e "s/^disable_overscan.*$/disable_overscan=1/"
|
||||||
|
else
|
||||||
|
printf "disable_overscan=1\n" >> /boot/config.txt
|
||||||
|
fi
|
||||||
|
else # enable overscan
|
||||||
|
sed -i /boot/config.txt -e "s/^disable_overscan.*$/disable_overscan=0/"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_overscan() {
|
||||||
|
whiptail --yesno "What would you like to do with overscan" 20 60 2 \
|
||||||
|
--yes-button Disable --no-button Enable
|
||||||
|
RET=$?
|
||||||
|
if [ $RET -eq 0 ] || [ $RET -eq 1 ]; then
|
||||||
|
set_overscan $RET;
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_change_pass() {
|
||||||
|
whiptail --msgbox "You will now be asked to enter a new password for the pi user" 20 60 1
|
||||||
|
passwd pi &&
|
||||||
|
whiptail --msgbox "Password changed successfully" 20 60 1
|
||||||
|
}
|
||||||
|
|
||||||
|
do_configure_keyboard() {
|
||||||
|
dpkg-reconfigure keyboard-setup &&
|
||||||
|
printf "Reloading keymap. This may take a short while\n" &&
|
||||||
|
invoke-rc.d keyboard-setup start
|
||||||
|
}
|
||||||
|
|
||||||
|
do_change_locale() {
|
||||||
|
dpkg-reconfigure locales
|
||||||
|
}
|
||||||
|
|
||||||
|
do_change_timezone() {
|
||||||
|
dpkg-reconfigure tzdata
|
||||||
|
}
|
||||||
|
|
||||||
|
do_memory_split() {
|
||||||
|
# Stop if /boot is not a mountpoint
|
||||||
|
if ! mountpoint -q /boot; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
MEMSPLIT=$(whiptail --menu "Set memory split" 20 60 10 \
|
||||||
|
"224" "224MiB for ARM, 32MiB for VideoCore" \
|
||||||
|
"192" "192MiB for ARM, 64MiB for VideoCore" \
|
||||||
|
"128" "128MiB for ARM, 128MiB for VideoCore" \
|
||||||
|
3>&1 1>&2 2>&3)
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
cp -a /boot/arm${MEMSPLIT}_start.elf /boot/start.elf
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_ssh() {
|
||||||
|
whiptail --yesno "Would you like the SSH server enabled or disabled?" 20 60 2 \
|
||||||
|
--yes-button Enable --no-button Disable
|
||||||
|
RET=$?
|
||||||
|
if [ $RET -eq 0 ]; then
|
||||||
|
update-rc.d ssh enable &&
|
||||||
|
invoke-rc.d ssh start &&
|
||||||
|
whiptail --msgbox "SSH server enabled" 20 60 1
|
||||||
|
elif [ $RET -eq 1 ]; then
|
||||||
|
update-rc.d ssh disable &&
|
||||||
|
whiptail --msgbox "SSH server disabled" 20 60 1
|
||||||
|
else
|
||||||
|
return $RET
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_finish() {
|
||||||
|
if [ -e /etc/profile.d/raspi-config.sh ]; then
|
||||||
|
rm -f /etc/profile.d/raspi-config.sh
|
||||||
|
sed -i /etc/inittab \
|
||||||
|
-e "s/^#\(.*\)#\s*RPICFG_TO_ENABLE\s*/\1/" \
|
||||||
|
-e "/#\s*RPICFG_TO_DISABLE/d"
|
||||||
|
telinit q
|
||||||
|
fi
|
||||||
|
whiptail --msgbox "Done" 20 60 1
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
FUN=$(whiptail --menu "Raspi-config" 20 80 10 --cancel-button Exit \
|
||||||
|
"info" "Information about this tool" \
|
||||||
|
"expand_rootfs" "Expand root partition to fill SD card" \
|
||||||
|
"overscan" "Change overscan" \
|
||||||
|
"change_pass" "Change password for 'pi' user" \
|
||||||
|
"configure_keyboard" "Set keyboard layout" \
|
||||||
|
"change_locale" "Set locale" \
|
||||||
|
"change_timezone" "Set timezone" \
|
||||||
|
"memory_split" "Change memory split" \
|
||||||
|
"ssh" "Enable or disable ssh server" \
|
||||||
|
"finish" "Finish config and don't start raspi-config at boot" \
|
||||||
|
3>&1 1>&2 2>&3)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 0;
|
||||||
|
else
|
||||||
|
"do_$FUN" || whiptail --msgbox "There was an error running do_$FUN" 20 60 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
17
sample_profile_d.sh
Normal file
17
sample_profile_d.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Part of raspi-config http://github.com/asb/raspi-config
|
||||||
|
#
|
||||||
|
# See LICENSE file for copyright and license details
|
||||||
|
|
||||||
|
# Should be installed to /etc/profile.d/raspi-config.sh to force raspi-config
|
||||||
|
# to run at initial login
|
||||||
|
|
||||||
|
# You may also want to set automatic login in /etc/inittab on tty1 by adding a
|
||||||
|
# line such as:
|
||||||
|
# 1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1 # RPICFG_TO_DISABLE
|
||||||
|
|
||||||
|
if [ $(id -u) -ne 0 ]; then
|
||||||
|
printf "\nNOTICE: this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'\n\n"
|
||||||
|
else
|
||||||
|
which raspi-config && exec raspi-config
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user