Poor WiFi signal in Ubuntu 18.04 LTS - wifi

I just shift to Ubuntu from Windows. Just after installing Ubuntu there "No WiFi adapter found" issue. I followed one YouTube video which fixed and helped to connect with the available wifi but, now I am having poor signal issue. I have also tried https://connectwww.com/how-to-solve-realtek-rtl8723be-weak-wifi-signal-problem-in-ubuntu/4625/ this answer and two three other answers from YouTube but no luck. What should I do get strong signal on my hp laptops?

installing wifi driver works for me and I have tried this in many hp laptops and it works fine there as well.
https://github.com/kindlerprince/Wifi_Solution
statuscheck()
{
if [ $1 -ne 0 ]
then
echo $2
echo "Exiting...."
exit 0
fi
}
CURR=$(cd "$(dirname "$0")" ; pwd -P )
echo $CURR
echo -n "Enter the sudo password : "
read -s password
cmd=$(echo $password | sudo -S lshw -C network -short 2>/dev/null | grep Wireless | awk '{print $2 " " $4}')
if sudo -n true ; then
echo "I got the sudo password"
else
echo "Wrong sudo password"
echo "Either replace the password in this script or give password via command line arguments"
echo "Exiting...."
exit 0
fi
#the return value is a single string having a space
#splitting by space and storing in a array
cmd=($cmd)
echo "Wifi Interface: "${cmd[0]}
echo "Wifi Driver: "${cmd[1]}
if [ -d "rtlwifi_new" ]
then
rm -rf rtlwifi_new
fi
git clone https://github.com/kindlerprince/rtlwifi_new.git
statuscheck $? "Failed to cloned Repository"
cd rtlwifi_new
make
statuscheck $? "Error occured in make"
sudo make install
statuscheck $? "Error occured in make"
sudo modprobe -rv ${cmd[1]}
sudo modprobe -v ${cmd[1]} ant_sel=2
sudo ip link set ${cmd[0]} up
sudo iw dev ${cmd[0]} scan
make clean
echo "Wifi Driver Installed Successfully"

Related

Docker syntax error end of file unexpected

Hello im new in docker and im having problem to build this:
MySQL install well
PhpMyadmin instal wel...
but in apache i have this error
error:
: not foundbin/pete_install.sh: 2:
/usr/local/bin/pete_install.sh: 110: Syntax error: end of file unexpected (expecting "then")
pete_install.sh
Line 1 to 10
#!/bin/bash
FILE=/var/www/html/.installed
if [ ! -f "$FILE" ]; then
echo "#######################################"
echo "Starting WordPress Pete installation..."
echo "#######################################"
rm -rf /var/www/html/Pete4
Linea 99 to 110
FILE=/var/www/.ssh/id_rsa.pub
if [ ! -f "$FILE" ]; then
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
fi
chmod 600 -R /var/www/.ssh/id_rsa
chmod 600 -R /var/www/.ssh/id_rsa.pub
apachectl -DFOREGROUND
#systemctl start
#/etc/init.d/apache2 reload
echo "Loading apache..."
full file https://pastebin.com/1f5a3pJY
Most of time, the error causes because you write your script on windows, the line break on windows is \r\n, while on linux it's \n.
You should install some tools to change format, e.g.:
$ sudo apt-get update
$ sudo apt-get install -y dos2unix
$ dos2unix /usr/local/bin/pete_install.sh

Docker stop/start resets to initial passwords

I've just started using docker by copy-pasting pre-made repos from github.
Here is the scenario and steps:
I've passed mysql/shell root password via environment variable -e and these passwords are set as expected inside entry.sh.
I then go inside container and reset shell/mysql root password to something different.
Now the main issue, each time I do docker stop + start from host, it resets passwords to the initial ones of step1.
Please suggest the changes so it retain the modified step2 passwords even I do docker start/stop.
Used entry.sh and dockerfile scripts can be checked from this github repo.
Thanks.
I just noticed that the entry.sh will always update the root password with $MYSQL_RANDOM_ROOT_PASSWORD on docker start. So assuming we already persist the /var/lib/mysql in the host, we can edit the entry.sh a bit to only update the password when /var/lib/mysql doesn't exists:
#!/bin/sh
# start apache
echo "Starting httpd"
httpd
echo "Done httpd"
# check if mysql data directory is nuked
# if so, install the db
echo "Checking /var/lib/mysql folder"
if [ ! -f /var/lib/mysql/ibdata1 ]; then
echo "Installing db"
mariadb-install-db --user=mysql --ldata=/var/lib/mysql > /dev/null
echo "Installed"
# from mysql official docker repo
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
echo >&2 'error: database is uninitialized and password option is not specified '
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_RANDOM_ROOT_PASSWORD'
exit 1
fi
# random password
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
echo "Using random password"
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
echo "Done"
fi
tfile=`mktemp`
if [ ! -f "$tfile" ]; then
return 1
fi
cat << EOF > $tfile
USE mysql;
DELETE FROM user;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY "$MYSQL_ROOT_PASSWORD" WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' WITH GRANT OPTION;
UPDATE user SET password=PASSWORD("") WHERE user='root' AND host='localhost';
FLUSH PRIVILEGES;
EOF
echo "Querying user"
/usr/bin/mysqld --user=root --bootstrap --verbose=0 < $tfile
rm -f $tfile
echo "Done query"
# setting ssh root password
if [ -z "$SSH_ROOT_PASSWORD" ]; then
echo >&2 'You need to specify SSH_ROOT_PASSWORD'
exit
fi
# Set root password to root, format is 'user:password'.
echo "root:$SSH_ROOT_PASSWORD" | chpasswd
fi;
echo "Generating ssh keys"
if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then
# generate fresh rsa key
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
fi
if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then
# generate fresh dsa key
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
fi
#prepare run dir
if [ ! -d "/var/run/sshd" ]; then
mkdir -p /var/run/sshd
fi
ssh-keygen -A
/usr/sbin/sshd
# start mysql
# nohup mysqld_safe --skip-grant-tables --bind-address 0.0.0.0 --user mysql > /dev/null 2>&1 &
echo "Starting mariadb database"
exec /usr/bin/mysqld --user=root --bind-address=0.0.0.0
Basically we just move this block of code to the if block above it

Host key verification failed in Jenkins

I have the following shell script, which is to install puppet agent in a remote machine. It worked perfectly if I run from my local ubuntu by cmd line as such: sh install_puppet_agent.sh
me#me:~$ cat install_puppet_agent.sh
#!/bin/bash
echo "Installing ..."
ssh -t me#puppet-agent << 'INSTALL_PUPPET_AGENT'
wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
echo "mepassword" | sudo -S dpkg -i puppet6-release-bionic.deb
sudo apt-get update
sudo apt install -y puppet-agent
sudo touch /etc/puppetlabs/puppet/puppet.conf
sudo chmod 777 /etc/puppetlabs/puppet/puppet.conf
echo "[main]" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "certname = puppetagent" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "server = puppet" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "environment = production" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "runinterval = 5m" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
INSTALL_PUPPET_AGENT
echo "done"
me#me:~$
The I created a simple execute shell job in jenkins by copying the content of install_puppet_agent.sh to the Build -> Execute shell area, then I clicked save/build now, I got this:
Installing ...
Host key verification failed.
done
I have googled a while, unable to figure it out. I need to confess I am new to Jenkins & Puppet. Thanks
Assuming this is not a security problem that you are facing, you should be ok with updating the content of ~/.ssh/known_hosts file on the Jenkins node the job executes on.
Examples how to do that:
https://www.thegeekdiary.com/how-to-fix-the-error-host-key-verification-failed/
I got around this issue simply by configure the jenkins job as such:
/home/me/install_puppet_agent.sh

Jenkins to automate deb reprepro repository creation/signing

Problem statement:
Can sign repos from inside normal terminal (also inside docker). From jenkins job, repo creation/signing fails. Job hangs.
Configuration:
Jenkins spawns docker container to create/sign deb repository.
Private and public keys all present.
gpg-agent installed on the docker container to sign the packages.
~/.gnupg/gpg.conf file has "use-agent" enabled
Progress:
Can start gpg-agent using jenkins on the docker container.
Can use gpg-preset-passphrase to cache passphrase.
Can use [OUTSIDE JENKINS]
reprepro --ask-passphrase -Vb . includedeb ${_repo_name} ${_pkg_location}
to fetch the passphrase from gpg-agent and sign the repo.
Problem:
from inside a jenkins job, the command "reprepro --ask-passphrase -Vb ..." hangs.
Code:
starting gpg-agent:
GPGAGENT=/usr/bin/gpg-agent
GNUPG_PID_FILE=${GNUPGHOME}/gpg-agent-info
GNUPG_CFG=${GNUPGHOME}/gpg.conf
GNUPG_CFG=${GNUPGHOME}/gpg-agent.conf
function start_gpg_agent {
GPG_TTY=$(tty)
export GPG_TTY
if [ -r "${GNUPG_PID_FILE}" ]
then
source "${GNUPG_PID_FILE}" count=$(ps lax | grep "${GPGAGENT}" | grep "$SSH_AGENT_PID" | wc -l)
if [ $count -eq 0 ]
then
if ! ${GPGAGENT} 2>/dev/null then
$GPGAGENT --debug-all --options ${BASE_PATH}/sign/gpg-agent.options \
--daemon --enable-ssh-support \
--allow-preset-passphrase --write-env-file ${GNUPG_PID_FILE}
if [[ $? -eq 0 ]]
then
echo "INFO::agent started"
else
echo "INFO::Agent could not be started. Exit."
exit -101
fi
fi
fi
else
$GPGAGENT --debug-all --options ${BASE_PATH}/sign/gpg-agent.options \
--daemon --allow-preset-passphrase --write-env-file ${GNUPG_PID_FILE}
fi
}
options file:
default-cache-ttl 31536000
default-cache-ttl-ssh 31536000
max-cache-ttl 31536000
max-cache-ttl-ssh 31536000
enable-ssh-support
debug-all
saving passphrase.
/usr/lib/gnupg2/gpg-preset-passphrase -v --preset --passphrase ${_passphrase} ${_fp}
finally (for completion), sign repo:
reprepro --ask-passphrase -Vb . includedeb ${_repo_name} ${_pkg_location}

Bash script for psql

Here is the shell script I am trying to run. It works when just run as a command but getting errors when run from the script.
#!/bin/bash
# sets CE IP addresses to act as LUS on pgsql
#Checks that user is logged in as root
if [ $(id -u) = "0" ]; then
#Asks user for IP of CE1
echo -n "Enter the IP address of your first CE's management module > "
read CE1
$(psql -U asm -d asm -t -c) echo """update zr_fsinstance set lu_order='1' where managementaccesspointhostname = '$CE1';"""
echo "LUS seetings have been completed"
else
#Warns user of error and sends status to stderr
echo "You must be logged in as root to run this script." >&2
exit 1
fi
Here is the error:
psql: option requires an argument -- 'c'
Try "psql --help" for more information.
update zr_fsinstance set lu_order='1' where managementaccesspointhostname = '10.134.39.139';
Instead of
$(psql -U asm -d asm -t -c) echo
"""update zr_fsinstance
set lu_order='1' where managementaccesspointhostname = '$CE1';"""
Try:
$(psql -U asm -d asm -t -c "UPDATE zr_fsinstance set lu_order='1'
where managementaccesspointhostname = ${CE1};")
OR (if you prefer):
`psql -U asm -d asm -t -c "UPDATE zr_fsinstance set lu_order='1'
where managementaccesspointhostname = ${CE1};"`

Resources