Skip to content

Instantly share code, notes, and snippets.

@lunatilia
Forked from Akkiesoft/minimal-raspbian2.sh
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lunatilia/9252ef73c5dd43c9f837 to your computer and use it in GitHub Desktop.
Save lunatilia/9252ef73c5dd43c9f837 to your computer and use it in GitHub Desktop.
MinimalなRaspbianを作るスクリプト(ほぼ最小構成構築用)
#!/bin/sh
#-----------------------------------------------------------------------------#
# raspi-minimalizer.sh (2015-05-28) | for Raspbian 2015-05-05
#-----------------------------------------------------------------------------#
# Basescript: Akkiesoft / minimal-raspbian2.sh
# https://gist.github.com/Akkiesoft/9873563
#
# Modified by Mitsuki Shirase@Lunatilia
#
# Usage:
# 1) Download this script.
# 2) sudo chmod +x ./raspi-minimalizer.sh
# 3) sudo ./raspi-minimalizer.sh
#-----------------------------------------------------------------------------#
USERID=`id -u`
if [ ${USERID} -ne 0 ]; then
echo "Usage: sudo ./raspi-minimalizer.sh"
exit 1
fi
# package list update
apt-get update
# rename /etc/network/interfaces.dpkg-old
INTERFACES='/etc/network/interfaces'
if [ -f ${INTERFACES}.dpkg-old ]; then
mv ${INTERFACES}.dpkg-old ${INTERFACES}.orig
fi
# listup remove package
XPKGS='x11-common xdg-utils gnome-themes-standard-data minecraft-pi epiphany-browser dillo midori penguinspuzzle lxde lxde-common lxde-icon-theme xkb-data xpdf fonts-freefont-ttf x2x desktop-file-utils libdbus-1-3 dbus gstreamer1.0 menu-xdg dhcpcd5 '`sudo dpkg --get-selections | grep -v "deinstall" | grep x11 | sed s/install//`
DOCS='libraspberrypi-doc manpages debian-reference-en debian-reference-common'
GCC='gcc-4.5-base gcc-4.6-base gcc-4.7-base'
DEV=`dpkg --get-selections | grep "\-dev" | grep -v "deinstall" | sed s/install//`
MEDIA='omxplayer v4l-utils shared-mime-info '`dpkg --get-selections | grep -v "deinstall" | grep sound | sed s/install//`
PYTHON='python3 python3-minimal '`dpkg --get-selections | grep -v "deinstall" | grep python | sed s/install//`
JAVA='java-common oracle-java8-jdk'
LEARNING='scratch squeak-vm squeak-plugins-scratch supercollider sonic-pi wolfram-engine'
WIFI='wireless-tools wpasupplicant'
# remove package
apt-get -y remove ${XPKGS} ${DOCS} ${GCC} ${DEV} ${MEDIA} ${PYTHON} ${JAVA} ${LEARNING} ${WIFI}
# install console-setup-mini (for Japanese keyboard setup)
apt-get -y install console-setup-mini
# run autoremove
apt-get -y autoremove
# run purge (All clear config files)
apt-get -y purge `dpkg -l | grep '^rc' | tr ' ' ':' | cut -d: -f 3`
# run apt-get upgrade
apt-get -y upgrade
# firmware update
rpi-update
# clean apt cache
apt-get -y autoclean
apt-get -y clean
# remove optional files
rm -rf /home/pi/python_games
rm -rf /opt/*
# rename /etc/network/interfaces.orig
if [ -f ${INTERFACES}.orig ]; then
mv ${INTERFACES}.orig ${INTERFACES}
fi
# regenerate swap file
/etc/init.d/dphys-swapfile stop
rm -f /var/swap
# clear logs
find /var/log/ -type f -exec rm -rf {} \;
# clear history
HISTCLEAR="./clear-history"
cat << EOF >> ${HISTCLEAR}
#-----------------------------------------------------------------------------#
# Usage: source clear-history
#-----------------------------------------------------------------------------#
export HISTSIZE=0
export HISTFILESIZE=0
rm -f ${HISTCLEAR}
EOF
echo "------------------------------------------------------------------------"
echo "Manualy run \"source ${HISTCLEAR}\" and reboot."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment