Advertisement
CGarces

new sh file

Oct 19th, 2016
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.68 KB | None | 0 0
  1.  
  2. #------------------------------------------------------------------------------------------------
  3. # Setup a Debian installation, for DietPi.
  4. #------------------------------------------------------------------------------------------------
  5. # NOTICE: Images created by non-DietPi staff, will NOT be officially supported by DietPi, unless authorized by DietPi.
  6. # NOTICE: There is no offical support for using these script/notes. However, exceptions may be made.
  7. #------------------------------------------------------------------------------------------------
  8. # Legend:
  9. # - Items that are commented out should not be used.
  10. # - Sections with '#???', are optional, depending on the device and its specs. (eg: does it need bluetooth?)
  11. #------------------------------------------------------------------------------------------------
  12.  
  13.  
  14. #------------------------------------------------------------------------------------------------
  15. #Packages
  16. #------------------------------------------------------------------------------------------------
  17.  
  18. #Jessie , unified apt sources.
  19. rm -f /etc/apt/sources.list.d/deb-multimedia.list
  20.  
  21. # - C2
  22. cat << _EOF_ > /etc/apt/sources.list
  23. deb http://ftp.debian.org/debian jessie main contrib non-free
  24. deb http://ftp.debian.org/debian jessie-updates main contrib non-free
  25. deb http://security.debian.org jessie/updates main contrib non-free
  26. deb http://ftp.debian.org/debian jessie-backports main contrib non-free
  27. deb http://ftp.debian.org/debian jessie-proposed-updates contrib non-free main
  28. _EOF_
  29.  
  30. # C2 stretch
  31. # cat << _EOF_ > /etc/apt/sources.list
  32. # deb http://ftp.debian.org/debian stretch main contrib non-free
  33. # deb http://ftp.debian.org/debian stretch-updates main contrib non-free
  34. # deb http://security.debian.org stretch/updates main contrib non-free
  35. # deb http://ftp.debian.org/debian stretch-backports main contrib non-free
  36. # deb http://ftp.debian.org/debian stretch-proposed-updates contrib non-free main
  37. # _EOF_
  38. # apt-get update
  39. # apt-get install busybox-static
  40. # apt-get upgrade -y
  41. # apt-get dist-upgrade -y
  42. # apt-get autoremove --purge -y
  43.  
  44. # rpi stretch
  45. # cat << _EOF_ > /etc/apt/sources.list
  46. # deb http://archive.raspbian.org/raspbian stretch main contrib non-free rpi
  47. # _EOF_
  48. # apt-get update
  49. # apt-get upgrade -y
  50. # apt-get dist-upgrade -y
  51. # apt-get autoremove --purge -y
  52.  
  53.  
  54. # deb-src http://ftp.debian.org/debian jessie main contrib non-free
  55. # deb-src http://ftp.debian.org/debian jessie-updates main contrib non-free
  56. # deb-src http://security.debian.org jessie/updates main contrib non-free
  57. # deb-src http://ftp.debian.org/debian jessie-backports main contrib non-free
  58. # deb-src http://ftp.debian.org/debian jessie-proposed-updates contrib non-free main
  59.  
  60.  
  61. #NOTE:
  62. #Apt mirror will get overwritten by: /DietPi/dietpi/func/dietpi-set_software apt-mirror default : during finalize.
  63.  
  64. # - Everything else (excluding RPi!)
  65. cat << _EOF_ > /etc/apt/sources.list
  66. deb http://ftp.debian.org/debian jessie main contrib non-free
  67. deb http://ftp.debian.org/debian jessie-updates main contrib non-free
  68. deb http://security.debian.org jessie/updates main contrib non-free
  69. deb http://ftp.debian.org/debian jessie-backports main contrib non-free
  70. # RPI UK mirror director is slow, unstable and unreliable -------------------------
  71. #deb http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian jessie main contrib non-free rpi
  72. _EOF_
  73.  
  74.  
  75. #Stretch
  76. # cat << _EOF_ > /etc/apt/sources.list
  77. # deb http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian stretch main contrib non-free rpi
  78. # _EOF_
  79. # RPI UK mirror director is slow, unstable and unreliable -------------------------
  80.  
  81.  
  82. #Remove following Jessie
  83. apt-get clean
  84. apt-get update
  85. apt-get purge libpng* cpp-* cpp ntpdate bluez bluetooth rsync dialog dhcpcd5 libsqlite* libxapian22 lua5.1 netcat-* make makedev ncdu plymouth openresolv shared-mime-in* tcpd strace tasksel* wireless-* xdg-user-dirs triggerhappy python* v4l-utils traceroute xz-utils ucf xauth zlib1g-dev xml-core aptitude* avahi-daemon rsyslog logrotate man-db manpages vim vim-common vim-runtime vim-tiny mc mc-data
  86.  
  87. #+Desktop images (Mostly desktop packages, but apply to non-desktop images also):
  88. apt-get purge libpod-* libpeas-* isc-dhcp-server gnome-* fonts-dejavu* eject dnsmasq* dns-root-data colord-data libturbojpeg1 libjasper* libjson* libwbclient* libwayland* golang-* libavahi* libtext* libweb* libpcsclite1 libxau6* libvpx1 libxc* dictionaries-* libgtk* miscfiles minicom lrzsz lxmenu-* x11-* zenity* yelp-*
  89.  
  90. #+armbian
  91. apt-get purge toilet toilet-fonts w-scan vlan weather-util* sysbench stress apt-transport-* cmake cmake-data device-tree-co* fping hddtemp haveged hostapd i2c-tools iperf ir-keytable libasound2* libmtp* libusb-dev lirc lsof ncurses-term pkg-config unicode-data rfkill pv mtp-tools m4 screen alsa-utils armbian-* autotools-dev bind9-host btrfs-tools bridge-utils cpufrequtils dvb-apps dtv-scan-table* evtest f3 figlet gcc gcc-4.8-* git git-man iozone3 ifenslave
  92. apt-get purge -y linux-jessie-root-*
  93.  
  94. #rm /etc/apt/sources.list.d/armbian.list
  95. rm -f /etc/init.d/resize2fs
  96. systemctl daemon-reload
  97. rm -f /etc/update-motd.d/*
  98.  
  99. #+RPi
  100. apt-get purge libraspberrypi-doc
  101.  
  102. #+ dev packages
  103. apt-get purge '\-dev$' linux-headers*
  104.  
  105.  
  106. apt-get autoremove --purge -y
  107.  
  108.  
  109. #install packages
  110. echo -e "CONF_SWAPSIZE=0" > /etc/dphys-swapfile
  111. apt-get install -y ethtool p7zip-full hfsplus iw debconf-utils xz-utils ifmetric fbset wpasupplicant resolvconf bc dbus bzip2 psmisc bash-completion cron whiptail sudo ntp ntfs-3g dosfstools parted hdparm pciutils usbutils zip htop wput wget fake-hwclock dphys-swapfile curl unzip ca-certificates console-setup console-data console-common keyboard-configuration wireless-tools wireless-regdb crda --no-install-recommends
  112.  
  113. #??? bluetooth if onboard device
  114. apt-get install -y bluetooth
  115.  
  116. #firmware
  117. apt-get install -y firmware-realtek firmware-ralink firmware-brcm80211 firmware-atheros -y --no-install-recommends
  118.  
  119. #------------------------------------------------------------------------------------------------
  120. #DIETPI STUFF
  121. #------------------------------------------------------------------------------------------------
  122.  
  123. #Mandatory DietPi Files
  124. wget https://github.com/Fourdee/DietPi/archive/master.zip -O /tmp/master.zip
  125. mkdir /boot/
  126. (cd /boot && unzip -oj /tmp/master.zip DietPi-master/dietpi.txt)
  127. (cd /boot && unzip -oj /tmp/master.zip DietPi-master/config.txt)
  128. unzip -o /tmp/master.zip -d /boot/ DietPi-master/dietpi/*
  129. mv /boot/DietPi-master/* /boot/
  130. rm -rf /boot/DietPi-master
  131. rm /tmp/master.zip
  132.  
  133.  
  134. #Delete any non-root user (eg: pi)
  135. userdel -f pi
  136.  
  137. #Remove folders
  138. rm -Rf /home
  139. rm -Rf /media
  140. rm -Rf /tmp/*
  141. rm -Rf /selinux
  142.  
  143. #Create DietPi common folders
  144. mkdir /DietPi
  145.  
  146. mkdir -p /mnt/dietpi_userdata
  147.  
  148. mkdir -p /mnt/usb_1
  149.  
  150. mkdir -p /mnt/samba
  151. mkdir -p /mnt/ftp_client
  152. mkdir -p /mnt/nfs_client
  153. echo -e "Samba client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/samba/readme.txt
  154. echo -e "FTP client mount can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/ftp_client/readme.txt
  155. echo -e "NFS client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/nfs_client/readme.txt
  156.  
  157. chmod +x /boot/dietpi/dietpi-logclear
  158. /boot/dietpi/dietpi-logclear 2
  159.  
  160. #FSTAB
  161. cp /boot/dietpi/conf/fstab /etc/fstab
  162.  
  163. #setup dietpi service
  164. echo 1 > /boot/dietpi/.install_stage
  165. cp /boot/dietpi/conf/dietpi-service /etc/init.d/dietpi-service
  166. chmod +x /etc/init.d/dietpi-service
  167. chmod +x /boot/dietpi/dietpi-ramdisk
  168. update-rc.d dietpi-service defaults 00 80
  169. service dietpi-service start
  170.  
  171. #Cron jobs
  172. cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi
  173. chmod +x /etc/cron.daily/dietpi
  174. cp /DietPi/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi
  175. chmod +x /etc/cron.hourly/dietpi
  176.  
  177. #Crontab
  178. cat << _EOF_ > /etc/crontab
  179. #Please use dietpi-cron to change cron start times
  180. SHELL=/bin/sh
  181. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  182.  
  183. # m h dom mon dow user command
  184. 17 * * * * root cd / && run-parts --report /etc/cron.hourly
  185. 25 1 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
  186. 47 1 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
  187. 52 1 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
  188. _EOF_
  189.  
  190. #ntp
  191. rm /etc/cron.daily/ntp &> /dev/null
  192. rm /etc/init.d/ntp &> /dev/null
  193.  
  194. #/etc/sysctl.conf | Check for a previous entry before adding this
  195. echo -e "vm.swappiness=1" >> /etc/sysctl.conf
  196.  
  197. #rc.local
  198. cat << _EOF_ > /etc/rc.local
  199. #!/bin/bash
  200. echo -e "\$(cat /proc/uptime | awk '{print \$1}') Seconds" > /var/log/boottime
  201. if (( \$(cat /DietPi/dietpi/.install_stage) == 1 )); then
  202.  
  203. /DietPi/dietpi/dietpi-services start
  204.  
  205. fi
  206. /DietPi/dietpi/dietpi-banner 0
  207. echo -e " Default Login:\n Username = root\n Password = dietpi\n"
  208. exit 0
  209. _EOF_
  210. chmod +x /etc/rc.local
  211.  
  212. #login,
  213. #echo -e "\n/DietPi/dietpi/login" >> /root/.bashrc
  214.  
  215. #Network
  216. cp /boot/dietpi/conf/network_interfaces /etc/network/interfaces
  217. /DietPi/dietpi/func/obtain_network_details
  218. # - enable allow-hotplug eth0 after copying.
  219. sed -i "/allow-hotplug eth/c\allow-hotplug eth$(sed -n 1p /DietPi/dietpi/.network)" /etc/network/interfaces
  220.  
  221. #Add ipv6 flags DietPi uses to disable IPV6 if set.
  222. cat << _EOF_ >> /etc/sysctl.conf
  223. net.ipv6.conf.all.disable_ipv6 = 0
  224. net.ipv6.conf.default.disable_ipv6 = 0
  225. net.ipv6.conf.lo.disable_ipv6 = 0
  226. _EOF_
  227.  
  228. #Netplug: Now installed and configured on demand by dietpi-config
  229. # cat << _EOF_ > /etc/netplug/netplugd.conf
  230. # eth*
  231. # wlan*
  232. # _EOF_
  233.  
  234. #htop cfg
  235. mkdir -p /root/.config/htop
  236. cp /boot/dietpi/conf/htoprc /root/.config/htop/htoprc
  237.  
  238. #Hosts
  239. cat << _EOF_ > /etc/hosts
  240. 127.0.0.1 localhost
  241. 127.0.1.1 DietPi
  242. ::1 localhost ip6-localhost ip6-loopback
  243. ff02::1 ip6-allnodes
  244. ff02::2 ip6-allrouters
  245. _EOF_
  246.  
  247. cat << _EOF_ > /etc/hostname
  248. DietPi
  249. _EOF_
  250.  
  251. #hdparm
  252. cat << _EOF_ >> /etc/hdparm.conf
  253.  
  254. #DietPi external USB drive. Power management settings.
  255. /dev/sda {
  256. #10 mins
  257. spindown_time = 120
  258.  
  259. #
  260. apm = 254
  261. }
  262. _EOF_
  263.  
  264. cat << _EOF_ >> /etc/bash.bashrc
  265. export \$(cat /etc/default/locale | grep LANG=)
  266. #DietPi Additions
  267. alias sudo='sudo ' # https://github.com/Fourdee/DietPi/issues/424
  268. alias dietpi-process_tool='/DietPi/dietpi/dietpi-process_tool'
  269. alias dietpi-letsencrypt='/DietPi/dietpi/dietpi-letsencrypt'
  270. alias dietpi-autostart='/DietPi/dietpi/dietpi-autostart'
  271. alias dietpi-cron='/DietPi/dietpi/dietpi-cron'
  272. alias dietpi-launcher='/DietPi/dietpi/dietpi-launcher'
  273. alias dietpi-cleaner='/DietPi/dietpi/dietpi-cleaner'
  274. alias dietpi-morsecode='/DietPi/dietpi/dietpi-morsecode'
  275. alias dietpi-sync='/DietPi/dietpi/dietpi-sync'
  276. alias dietpi-backup='/DietPi/dietpi/dietpi-backup'
  277. alias dietpi-bugreport='/DietPi/dietpi/dietpi-bugreport'
  278. alias dietpi-services='/DietPi/dietpi/dietpi-services'
  279. alias dietpi-config='/DietPi/dietpi/dietpi-config'
  280. alias dietpi-software='/DietPi/dietpi/dietpi-software'
  281. alias dietpi-update='/DietPi/dietpi/dietpi-update'
  282. alias dietpi-drive_manager='/DietPi/dietpi/dietpi-drive_manager'
  283. alias emulationstation='/opt/retropie/supplementary/emulationstation/emulationstation'
  284. alias opentyrian='/usr/local/games/opentyrian/run'
  285.  
  286. alias cpu='/DietPi/dietpi/dietpi-cpuinfo'
  287. alias dietpi-logclear='/DietPi/dietpi/dietpi-logclear'
  288. treesize()
  289. {
  290. du -k --max-depth=1 | sort -nr | awk '
  291. BEGIN {
  292. split("KB,MB,GB,TB", Units, ",");
  293. }
  294. {
  295. u = 1;
  296. while (\$1 >= 1024)
  297. {
  298. \$1 = \$1 / 1024;
  299. u += 1;
  300. }
  301. \$1 = sprintf("%.1f %s", \$1, Units[u]);
  302. print \$0;
  303. }
  304. '
  305. }
  306. _EOF_
  307.  
  308.  
  309. #fakehwclock - allow times in the past
  310. sed -i "/FORCE=/c\FORCE=force" /etc/default/fake-hwclock
  311.  
  312. #wifi dongles
  313. echo -e "options 8192cu rtw_power_mgnt=0" > /etc/modprobe.d/8192cu.conf
  314. echo -e "options 8188eu rtw_power_mgnt=0" > /etc/modprobe.d/8188eu.conf
  315.  
  316. #Set swapfile size
  317. echo -e "CONF_SWAPSIZE=0" > /etc/dphys-swapfile
  318.  
  319. #nano /etc/systemd/logind.conf
  320. #NAutoVTs=1
  321.  
  322. #nano /etc/default/console-setup
  323. #Reduce gettys ACTIVE_CONSOLES="/dev/tty[1-2]"
  324.  
  325. systemctl disable getty@tty[2-6].service
  326. #systemctl disable serial-getty@ttyS0.service
  327.  
  328. #NTPd - remove systemd's version
  329. systemctl disable systemd-timesync
  330.  
  331. #Remove rc.local from /etc/init.d
  332. update-rc.d -f rc.local remove
  333. rm /etc/init.d/rc.local
  334. rm /lib/systemd/system/rc-local.service
  335.  
  336. cat << _EOF_ > /etc/systemd/system/rc-local.service
  337. [Unit]
  338. Description=/etc/rc.local Compatibility
  339. After=dietpi-service.service
  340.  
  341. [Service]
  342. Type=idle
  343. ExecStart=/etc/rc.local
  344. StandardOutput=tty
  345. RemainAfterExit=yes
  346.  
  347. [Install]
  348. WantedBy=multi-user.target
  349. _EOF_
  350. systemctl enable rc-local.service
  351. systemctl daemon-reload
  352.  
  353. #Shutdown SSH/Dropbear before reboot
  354. cat << _EOF_ > /etc/systemd/system/kill-ssh-user-sessions-before-network.service
  355. [Unit]
  356. Description=Shutdown all ssh sessions before network
  357. DefaultDependencies=no
  358. Before=network.target shutdown.target
  359.  
  360. [Service]
  361. Type=oneshot
  362. ExecStart=/usr/bin/killall sshd && /usr/bin/killall dropbear
  363.  
  364. [Install]
  365. WantedBy=poweroff.target halt.target reboot.target
  366. _EOF_
  367. systemctl enable kill-ssh-user-sessions-before-network
  368. systemctl daemon-reload
  369.  
  370.  
  371. dpkg-reconfigure tzdata #Europe > London
  372. dpkg-reconfigure keyboard-configuration #Keyboard must be plugged in for this to work!
  373. dpkg-reconfigure locales # en_GB.UTF8 as default and only installed locale
  374.  
  375. #??? RPI ONLY: Scroll lock fix for RPi by Midwan: https://github.com/Fourdee/DietPi/issues/474#issuecomment-243215674
  376. cat << _EOF_ > /etc/udev/rules.d/50-leds.rules
  377. ACTION=="add", SUBSYSTEM=="leds", ENV{DEVPATH}=="*/input*::scrolllock", ATTR{trigger}="kbd-scrollock"
  378. _EOF_
  379.  
  380. #------------------------------------------------------------------------------------------------
  381. #A Unique HW_MODEL index will need to be assigned and coded into the DietPi sourcecode.
  382. # If you are not creating a pull request for this, then:
  383. #
  384. # Email:
  385. # Address='daniel.knight@dietpi.com'
  386. # Subject title='Unique HW_MODEL Index Request [DEVICENAME]' | Where DEVICENAME could be 'Odroid C3'
  387. #------------------------------------------------------------------------------------------------
  388.  
  389. #Once you have the updated sourcecode, update the file '/DietPi/dietpi/dietpi-obtain_hw_model'
  390.  
  391. #Finalise system
  392. /DietPi/dietpi/finalise
  393.  
  394. #??? Does this device have a unique HW ID index and file? check /DietPi/dietpi/dietpi-obtain_hw_model
  395. echo ID > /etc/.dietpi_hw_model_identifier
  396.  
  397. #Power off system
  398.  
  399. #Read image
  400.  
  401. #Resize 2nd parition to mininum size +50MB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement