Possum
Posts: 34
Joined: Thu Mar 22, 2012 2:32 pm
Contact: Website

Custome Install Script

Fri Jun 05, 2020 7:18 pm

Hi
I use my pi(s) headless. Is there a way I can run a script to do this. As I need to install all this everytime I reinstall.


sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install apache2 -y
sudo apt-get install php -y
sudo apt-get install mariadb-server
sudo mysql -u root -p
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';
sudo apt-get install phpmyadmin

Thank You...

pfletch101
Posts: 623
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Custome Install Script

Fri Jun 05, 2020 9:00 pm

Possum wrote:
Fri Jun 05, 2020 7:18 pm
Hi
I use my pi(s) headless. Is there a way I can run a script to do this. As I need to install all this everytime I reinstall.


sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install apache2 -y
sudo apt-get install php -y
sudo apt-get install mariadb-server
sudo mysql -u root -p
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';
sudo apt-get install phpmyadmin

Thank You...
Probably the safest way to handle this is to keep the script as a text file on whatever system you use to create your boot SDs, and copy it to the boot partition of the created card with your headless setup files. Once you have successfully booted the new card, use sh to run the script. You may have to put the commands to mysql in a separate file and redirect the mysql CLI to them. I really wouldn't recommend trying to completely automate this on first boot, since you may not know if something goes wrong along the way.

Return to “Advanced users”