Guest User

Untitled

a guest
Jan 27th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -o errexit
  4. set -o nounset
  5.  
  6. sudo bash
  7.  
  8. # set time GMT +7
  9. ln -fs /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime
  10.  
  11. #change hostname
  12. cat >> /etc/hostname << EOF
  13.  
  14. SMART MEDICINE FINDER
  15.  
  16. EOF
  17.  
  18. sudo bash
  19.  
  20. # update
  21. apt-get update -y
  22.  
  23. # install apache
  24. apt-get install apache2 apache2-doc apache2-utils -y
  25. apt-get install libapache2-mod-php5 php5 php-pear php5-xcache -y
  26. apt-get install php5-mysql -y
  27. apt-get install mysql-server mysql-client
  28.  
  29. # Function
  30. usage(){
  31. cat << _EOF_
  32.  
  33. Usage: ${0} "ROOT PASSWORD"
  34.  
  35. with "ROOT PASSWORD" the desired password for the database root user.
  36.  
  37. Use quotes if your password contains spaces or other special characters.
  38. _EOF_
  39. }
  40.  
  41. # Predicate
  42. is_mysql_root_password_set(){
  43. ! mysqladmin --user=root status > /dev/null 2>&1
  44. }
  45.  
  46.  
  47. is_mysql_command_available(){
  48. which mysql > /dev/null 2>&1
  49. }
  50.  
  51. if [ "$#" -ne "1" ]; then
  52. echo "Expected 1 argument, got $#" >&2
  53. usage
  54. exit 2
  55. fi
  56.  
  57. #}}}
  58. #{{{ Variables
  59. db_root_password="${1}"
  60. #}}}
  61.  
  62. # Script proper
  63.  
  64. if ! is_mysql_command_available; then
  65. echo "The MySQL/MariaDB client mysql(1) is not installed."
  66. exit 1
  67. fi
  68.  
  69. if is_mysql_root_password_set; then
  70. echo "Database root password already set"
  71. exit 0
  72. fi
  73.  
  74. mysql --user=root <<_EOF_
  75. UPDATE mysql.user SET Password=PASSWORD('rootraspberry') WHERE User='root';
  76. DELETE FROM mysql.user WHERE User='';
  77. DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
  78. DROP DATABASE IF EXISTS test;
  79. DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
  80. FLUSH PRIVILEGES;
  81. _EOF_
  82.  
  83. #create php
  84. cat >> index.php << EOF
  85.  
  86. index.php.d
  87.  
  88. EOF
  89.  
  90. #install samba
  91. apt-get install samba samba-common-bin -y
  92. apt install samba samba-common-bin -y
  93.  
  94. echo "#======================= Global Settings =======================" > /etc/samba/smb.conf
  95. echo "[global]" >> /etc/samba/smb.conf
  96. echo "workgroup = WORKGROUP" >> /etc/samba/smb.conf
  97. echo "wins support = yes" >> /etc/samba/smb.conf
  98.  
  99.  
  100. cat >> /etc/samba/smb.conf << EOF
  101.  
  102. [MyPiServer]
  103. comment = Pi Server Folder
  104. path = /var/www/html
  105. browseable = yes
  106. writeable = yes
  107. only guest = no
  108. create mask = 0777
  109. directory mask = 0777
  110. public = no
  111. read only = no
  112. force user = root
  113.  
  114. [pihome]
  115. comment= Pi
  116. Home path=/home/pi
  117. browseable=Yes
  118. writeable=Yes
  119. only guest=no
  120. create mask=0777
  121. directory mask=0777
  122. public=no
  123.  
  124. EOF
  125.  
  126. smbpasswd -a pi
  127.  
  128. #install remote
  129. apt-get install xrdp
  130.  
  131. apt-get update
Add Comment
Please, Sign In to add comment