Shell script to setup Xubuntu 16.04 - linux

I wanted to create a file I could run every time I installed Xubuntu so I could have my setup ready easier. So I created a python file with the following text to install software, I then set up permissions and ran the file.
It didn't ask for my password and didn't do anything. I made sure I don't already have google chrome installed.
Code:
#!/usr/bin/python
import os
os.system('cd /tmp')
os.system('wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb')
os.system('sudo dpkg -i google-chrome-stable_current_amd64.deb')
os.system('sudo apt-get -f install')
Update:
I have rewritten it as a shell script:
#!/bin/bash
sudo apt-get update
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get -f install
sudo apt purge gnome-software gnome-sudoku gnome-mines thunderbird pidgin firefox libreoffice
sudo add-apt-repository ppa:mystic-mirage/pycharm
sudo apt-add-repository ppa:richardgv/compton
sudo apt-get update
sudo apt-get install pycharm-community gnome-boxes compton synaptic abiword gnumeric ubuntu-restricted-extras
compton -CG
I would like to know if there is a line I can add to have the compositor compton and the terminal for XFCE to start upon startup.

Related

Installing MySQL on CentOS using shell script

I am writing a script where I should install MySQL on my Centos hard disk when I run it.
I downloaded the following :
mysql-apt-config_0.8.5-1_all.deb
But I don't figure out how to install it from the shell script.
I am new to Linux and any help is appreciated !!
Since Centos is yum package manager just run the following commands to install MySql
If you are using Centos 7, you need to first add the repository as follows
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
To install MySql on Centos, we run
sudo yum install mysql-server
sudo systemctl start mysqld
Note: .deb files are only used for Debian based Linux Distros. Centos uses .rpm files.
Try to save following command in a shell file(extension with .sh) and run with sudo.
#!/bin/bash**strong text**
export http_proxy= $Write proxy
export https_proxy= $ write proxy
sudo -E yum -y update
sudo -E yum -y install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo -E yum -y update
sudo -E yum -y install mysql-server
sudo systemctl start mysqld
sleep 1s
mysql -u root <<-EOF
UPDATE mysql.user SET Password=PASSWORD('123') WHERE User='root';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.db WHERE Db='test' OR Db='test_%';
FLUSH PRIVILEGES;
EOF

Ubuntu 16.04 error with apt-get

Yesterday I updated Ubuntu from 14.04 to 16.04, when I tried to install git, I got this error:
The package linux-headers-4.4.0-65 needs to be reinstalled, but I
can't find an archive for it.
Then I tried to install another software, to the same error.
First you need to
sudo apt-get update
Then
sudo apt-get install git
I had a similar problem on Kali-Linux once. The thing that worked for me was:
sudo dpkg --configure -a
sudo apt-get -f install
sudo apt-get update && sudo apt-get dist-upgrade

How to answer an apt-get configuration change prompt on Travis-CI, in this case for couchdb 1.5.0

I am trying run a specific version of couchdb on travis-ci I do this by following the offical apt-get instructions from couchdb
Part of the installation is a prompt for what to do with an old configuration file. See the following:
Installing new version of config file /etc/logrotate.d/couchdb ...
Configuration file `/etc/couchdb/local.ini'
==> Deleted (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** local.ini (Y/I/N/O/D/Z) [default=N] ?
This causes travis-ci to hang and the build to fail.
Here is the travis-ci i have tried with and without the sudo rm and a handful of otherthings.
language: python
php:
- 2.7
install: "pip install -r requirements.txt"
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sudo apt-get install python-software-properties -y
- sudo add-apt-repository ppa:couchdb/stable -y
- sudo apt-get update -yq
- sudo apt-get remove couchdb couchdb-bin couchdb-common -yf
- sudo rm /etc/couchdb/local.ini
- sudo apt-get install -Vy couchdb
- sudo service couchdb start
before_script:
- curl -X PUT localhost:5984/njb_tests
script: python run-tests.py
You can see the different things i have tried by looking at my commit history:
https://github.com/Victory/notice-javascript-bugs/commits/master/.travis.yml
Hello my Frind its quite easy
I believe this command will do the trick
The 100% Working way no excuse no mercy!!
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install couchdb
The Softer way probally working
export DEBIAN_FRONTEND=noninteractive
apt-get -o Dpkg::Options::="--force-confnew" install -y
The Right way
on shell or in code do
export DEBIAN_FRONTEND=noninteractive
then
sudo apt-get -q -y install couchdb
It will assume “yes” to everything (and do it quietly)
you need to watch Debconf is the name of the tool. That page should help you get going with everything you want to know. debconf man page
The expect script method
you get asked for package maintainer or a password you should set on apt-get do here a simple example from a server that asks to set password on apt-get install
To keep your existing password, leave this blank.
Password for SYSDBA:
then you run it with this script below to do the input
#!/usr/bin/expect
spawn dpkg-reconfigure firebird2.5-superclassic -freadline
expect "Enable Firebird server?"
send "Y\r"
expect "Password for SYSDBA:"
send "newpwd\r"
# done
expect eof
Working example for your case is
- /usr/bin/expect 'spawn sudo apt-get install -Vy couchdb \n expect "*** local.ini (Y/I/N/O/D/Z) [default=N] ?" \n send "Y\r"

Docker : initial installation script fails (ubuntu 13.04 , kernel 3.8+)

I created this script according to docker.io installation instructions for Ubuntu 13.04 with 3.8+ kernel, but script is interrupted as lxc-docker installation fihishes.
ssh -o StrictHostKeychecking=no -t -t -i $CERT $USER#$SERVER <<'ENDSSH'
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository -y ppa:dotcloud/lxc-docker
sudo DEBIAN_FRONTEND=noninteractive apt-get -y update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install lxc-docker
echo "some other actions here..."
exit #SSH session
ENDSSH
exit
Last line of installation process is :
Processing triggers for ureadahead ...
and then it will stay on command line, but that is not good. I want to install few other things and exit properly by exit command from remote machine.
Where is problem here ?
I do not want to use some more complex remote provisioning tools like puppet/chef/salt , would be great to have already prepared 100% reliable docker installation scripts for various OS.
Thank you

Not able to install youtube-dl

I have tried almost everything I could find on google but could not install youtube-dl on Debian Mint.
Try 1
Installed and updated with following commands:
sudo apt-get install youtube-dl
sudo youtube-dl -U
But when tried
youtube-dl http://www.youtube.com/watch?v=dwYatpwrs8s
Then I got
Hi! We changed distribution method and now youtube-dl needs to update itself one more time.
This will only happen once. Simply press enter to go on. Sorry for the trouble!
From now on, get the binaries from http://rg3.github.io/youtube-dl/download.html, not from the git repository.
Then I went to http://rg3.github.io/youtube-dl/download.html and followed the installation instructions:
Try 2
sudo wget http://youtube-dl.org/downloads/2013.05.23/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
Got the same error about the distribution change and new link.
Try 3
So I installed pip on my debian first and ran
sudo pip install --upgrade youtube_dl
But I am still getting same error and I have no idea what to do about it.
Just re-execute sudo youtube-dl -U and press Enter to update to the latest version. With your second try, you installed it a second time (to /usr/local/bin/ instead of /usr/bin) - you want only one.
Alternatively, simply uninstall youtube-dl with sudo apt-get remove -y youtube-dl. That should make the local version (/usr/local/bin/youtube-dl) the first one in your PATH again - if your PATH contains /usr/local/bin. If it doesn't, you can also just install youtube-dl to /usr/bin, with the following commands:
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/bin/youtube-dl
sudo chmod a+x /usr/bin/youtube-dl
If you already install remove it:
sudo rm /usr/bin/youtube-dl
sudo apt-get remove -y youtube-dl
Try the following command
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
hash -r
I solved the issue with this:
https://github.com/ytdl-org/youtube-dl/issues/3908
Use the following commands to update:
sudo rm /usr/bin/youtube-dl # or apt-get remove -y youtube-dl
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl

Resources