I've been trying to use the stock templates from the wso2 website to deploy wso2 to AWS. The CloudFormation stack fails to create because the auto scaler fails to create.
I checked the EC2 instances and the actual instance is running and healthy.
I SSH'ed to the instance and ran:
grep -ni 'error\|failure' $(sudo find /var/log -name cfn-init\* -or -name cloud-init\*)
to check the log files for errors or failures. I didn't find any.
I then tried to run:
/usr/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2MINode1AutoScalingGroup --region ${AWS::Region}
from the correct instance. I filled in the correct information manually when I ran the command on the instance. I pulled this command from the YAML file from the wso2 website. This command returned an Access Denied error for the stack.
Any help would be greatly appreciated. I feel like I'm over looking something simple. I included the LaunchConfiguration and the template for the Auto Scaling group below if that's useful. Happy to provide other information.
WSO2MINode1LaunchConfiguration:
Type: 'AWS::AutoScaling::LaunchConfiguration'
Properties:
ImageId: !FindInMap
- WSO2APIMAMIRegionMap
- !Ref 'AWS::Region'
- !Ref OperatingSystem
InstanceType: !Ref WSO2InstanceType
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: '20'
VolumeType: gp2
DeleteOnTermination: 'true'
KeyName: !Ref KeyPairName
SecurityGroups:
- !Ref WSO2MISecurityGroup
UserData: !Base64
'Fn::Sub': |
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
export PATH=~/.local/bin:$PATH
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt install -y puppet nfs-common
apt install -y python-pip
apt install -y python3-pip
pip3 install boto3
pip install boto3
sed -i '/\[main\]/a server=puppet' /etc/puppet/puppet.conf
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
yum install -y epel-release zip unzip nfs-utils
yum install -y python-pip
pip install boto3
rpm -Uvh https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm
yum install -y puppet-agent
echo $'[main]\nserver = puppet\ncertname = agent3\nenvironment = production\n\runinterval = 1h' > /etc/puppetlabs/puppet/puppet.conf
fi
pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
export PuppetmasterIP=${PuppetMaster.PrivateIp}
echo "$PuppetmasterIP puppet puppetmaster" >> /etc/hosts
export MI_HOST=${WSO2APIMLoadBalancer.DNSName}
export MI_PORT=8290
service puppet restart
sleep 150
export FACTER_profile=mi
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
puppet agent -vt >> /var/log/puppetlog.log
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
/opt/puppetlabs/bin/puppet agent -vt >> /var/log/puppetlog.log
fi
sleep 30
service puppet stop
sh /usr/lib/wso2/wso2am/4.1.0/wso2mi-4.1.0/bin/micro-integrator.sh start
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
echo "/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2MINode1AutoScalingGroup --region ${AWS::Region}" >> /home/ubuntu/cfn-signal.txt
/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2MINode1AutoScalingGroup --region ${AWS::Region}
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
/usr/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2MINode1AutoScalingGroup --region ${AWS::Region}
fi
echo 'export HISTTIMEFORMAT="%F %T "' >> /etc/profile.d/history.sh
cat /dev/null > ~/.bash_history && history -c
DependsOn:
- WSO2MISecurityGroup
- WSO2APIMSecurityGroup
- PuppetMaster
WSO2MINode1AutoScalingGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
Properties:
LaunchConfigurationName: !Ref WSO2MINode1LaunchConfiguration
DesiredCapacity: 1
MinSize: 1
MaxSize: 1
VPCZoneIdentifier:
- !Ref WSO2APIMPrivateSubnet1
- !Ref WSO2APIMPrivateSubnet2
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2MIInstance
PropagateAtLaunch: 'true'
CreationPolicy:
ResourceSignal:
Count: 1
Timeout: PT30M
UpdatePolicy:
AutoScalingRollingUpdate:
MaxBatchSize: '2'
MinInstancesInService: '1'
PauseTime: PT10M
SuspendProcesses:
- AlarmNotification
WaitOnResourceSignals: false
DependsOn:
- WSO2APIMNode1AutoScalingGroup
- WSO2APIMNode2AutoScalingGroup
Thank you!
Related
macOS Catalina, installed jenv 0.5.4 using homebrew, using zsh, followed all the steps listed in https://www.jenv.be/
In terminal I have the following error
Last login: Tue Dec 22 10:10:15 on ttys002
/usr/local/Cellar/jenv/0.5.4/libexec/libexec/jenv-refresh-plugins: line 14: /Users/username/.jenv/jenv.version: Permission denied
The below is the code from jenv-refresh-plugins
#!/usr/bin/env bash
# Summary: Refresh plugins links
resolve_link() {
$(type -p greadlink readlink | head -1) "$1"
}
set -e
[ -n "$JENV_DEBUG" ] && set -x
FORCE_REFRESH=0
if [ ! -f "${JENV_ROOT}/jenv.version" ]; then
echo "NONE" > ${JENV_ROOT}/jenv.version
fi
if [ "$1" = "--complete" ]; then
echo "--force"
exit
fi
if [ "$1" = "--force" ]; then
FORCE_REFRESH=1
fi
lastVersion=$(cat "${JENV_ROOT}/jenv.version" || echo "none")
currentVersion=$(jenv --version)
if [ ! "$lastVersion" == "$currentVersion" ] || [ $FORCE_REFRESH == "1" ]; then
echo "jenv has been updated, process to refresh plugin links"
for path in "${JENV_ROOT}/plugins/"*; do
if [ -L "$path" ]; then
pluginName=$(basename $path)
echo "Refresh plugin $pluginName"
ln -sfn "${JENV_INSTALL_DIR}/available-plugins/$pluginName" "${JENV_ROOT}/plugins/$pluginName"
fi
done
fi
echo "$currentVersion" > "${JENV_ROOT}/jenv.version"
jenv doctor
[OK] No JAVA_HOME set
[OK] Java binaries in path are jenv shims
[OK] Jenv is correctly loaded
Any help, much appreciated.
I just experienced this same issue on mac- it was caused because for some reason the folder /Users/username/.jenv had become locked.
I couldn't find a way to unlock it, so i just copied it to another directory, then ran sudo rm -rf /Users/username/.jenv , copied it back, and that has solved the problem.
I want to create a customized openstack OpenSUSE15-image that contains some custom software and a graphical interface. I have used an existing OpenSUSE15.0 image and packer to build that image. It works fine. The packer json file is as follows:
"builders": [
{
"type" : "openstack",
"ssh_username" : "root",
"image_name": "OpenSUSE_15_custom_kde",
"source_image": "OpenSUSE 15",
"flavor": "m1.medium",
"networks": "public-network"
}
],
"provisioners":[
{
"type": "shell",
"inline": [
"sleep 10",
"sudo -s",
"zypper --gpg-auto-import-keys refresh",
"zypper -n up -y",
"zypper -n clean -a",
"zypper -n addrepo -f http://download.opensuse.org/repositories/devel\\:/languages\\:/R\\:/patched/openSUSE_Leap_15.0/ R-patched",
"zypper -n addrepo -f http://download.opensuse.org/repositories/devel\\:/languages\\:/R\\:/released/openSUSE_Leap_15.0/ R-released",
"zypper --gpg-auto-import-keys refresh",
"zypper -n install -y R-base R-base-devel R-recommended-packages rstudio",
"zypper -n clean -a",
"zypper --non-interactive install -y -t pattern kde kde_plasma devel_kernel devel_python3 devel_C_C++ office x11",
"zypper -n install xrdp",
"zypper -n clean -a",
"zypper -n dup -y",
"systemctl enable xrdp",
"systemctl start xrdp",
"cloud-init clean --logs",
"zypper -n install -y cloud-init growpart yast2-network yast2-services-manager acpid",
"cat /dev/null > /etc/udev/rules.d/70-persistent-net.rules",
"systemctl disable cloud-init.service cloud-final.service cloud-init-local.service cloud-config.service",
"systemctl enable cloud-init.service cloud-final.service cloud-init-local.service cloud-config.service sshd",
"sudo systemctl stop firewalld",
"sudo systemctl disable firewalld",
"sed -i 's/GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=0/g' /etc/default/grub",
"exec grub2-mkconfig -o /boot/grub2/grub.cfg '$#'",
"systemctl restart cloud-init",
"systemctl daemon-reload",
"cat /dev/null > ~/.bash_history && history -c && sudo su",
"cat /dev/null > /var/log/wtmp",
"cat /dev/null > /var/log/btmp",
"cat /dev/null > /var/log/lastlog",
"cat /dev/null > /var/run/utmp",
"cat /dev/null > /var/log/auth.log",
"cat /dev/null > /var/log/kern.log",
"cat /dev/null > ~/.bash_history && history -c",
"rm ~/.ssh/authorized_keys"
]
},
{
"type": "file",
"source": "./cloud_init/cloud.cfg",
"destination": "/etc/cloud/cloud.cfg"
}
]
}
There are no errors in the building and provisioning phases with packer.
In a second stage, when this base image is spawned through a heat template via the openstack client, I want some personalized tasks to be completed. User creation, granting ssh-access (including adjusting the sshd_config file...). This is done through the init_image.sh file.
#!/bin/bash
useradd -m $USERNAME -p $PASSWD -s /bin/bash
usermod -a -G sudo $USERNAME
tee /etc/ssh/banner <<EOF
You are one lucky user, if you bear the key...
EOF
tee /etc/ssh/sshd_config <<EOF
## SOME IMPORTANT SSHD CONFIGURATIONS
EOF
sudo -u $USERNAME -H sh -c 'cd ~;mkdir ~/.ssh/;echo "$SSHPUBKEY" > ~/.ssh/authorized_keys;chmod -R 700 ~/.ssh/;chmod 600 ~/.ssh/authorized_keys;'
systemctl restart sshd.service
voldata_dev="/dev/disk/by-id/virtio-$(echo $VOLDATA | cut -c -20)"
mkfs.ext4 $voldata_dev
mkdir -pv /home/$USERNAME/share
echo "$voldata_dev /home/$USERNAME/share ext4 defaults 1 2" >> /etc/fstab
mount /home/$USERNAME/share
chown -R $USERNAME:users /home/$USERNAME/share/
systemctl enable xrdp
systemctl start xrdp
For this purpose, I have created the following heat template.
heat_template_version: "2018-08-31"
description: "version 2017-09-01 created by HOT Generator at Fri, 05 Jul 2019 12:56:22 GMT."
parameters:
username:
type: string
label: User Name
description: This is the user name, and will be also the name of the key and the server
default: test
imagename:
type: string
label: Image Name
description: This is the Name of the Image e.g. Ubuntu 18.04
default: "OpenSUSE Leap 15"
ssh_pub_key:
type: string
label: ssh public key
flavorname:
type: string
label: Flavor Name
description: This is the Name of the Flavor e.g. m1.small
default: "m1.small"
vol_size:
type: number
label: Volume Size
description: This is the size of the volume that should be attached in GB
default: 10
password:
type: string
label: password
description: This is the su password and user password
resources:
init:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config:
str_replace:
template:
{get_file: init_image.sh}
params:
$USERNAME: {get_param: username}
$SSHPUBKEY: {get_param: ssh_pub_key}
$PASSWD: {get_param: password}
$VOLDATA: {get_resource: volume}
my_key:
type: "OS::Nova::KeyPair"
properties:
name:
list_join:
["_", [ {get_param: username}, 'key']]
public_key: {get_param: ssh_pub_key}
my_server:
type: "OS::Nova::Server"
properties:
block_device_mapping_v2: [{ device_name: "vda", image : { get_param : imagename }, delete_on_termination : "false", volume_size: 20 }]
name: {get_param: username}
flavor: {get_param: flavorname}
key_name: {get_resource: my_key}
admin_pass: {get_param: password}
user_data_format: RAW
user_data: {get_resource: init}
networks:
- network: "public-network"
depends_on:
- my_key
- init
- volume
volume:
type: "OS::Cinder::Volume"
properties:
# Size is given in GB
size: {get_param: vol_size}
name:
list_join: ["-", ["vol_",{get_param: username }]]
volume_attachment:
type: "OS::Cinder::VolumeAttachment"
properties:
volume_id: { get_resource: volume }
instance_uuid: { get_resource: my_server }
depends_on:
- volume
outputs:
instance_ip:
description: The IP address of the deployed instances
value: { get_attr: [my_server, first_address] }
If I use the original image in the template I have no problems (however, the building process takes very very long) and I need to restart to have the graphical KDE interface.
However, if I use the image build with packer, my user_data are ignored? I cannot log in, the user personalized user is not created... What have I missed? Why does it not work? As you see, I clean cloud-init, restart the services... I am stuck big time...
UPDATE
Here is the accesible boot-log from the machine.
UPDATE 2
This is the output of cloud-init analyze show:
-- Boot Record 01 --
The total time elapsed since completing an event is printed after the "#" character.
The time the event takes is printed after the "+" character.
Starting stage: init-local
|`->no cache found #00.01000s +00.00000s
|`->no local data found from DataSourceOpenStackLocal #00.04700s +15.23000s
Finished stage: (init-local) 15.31200 seconds
Starting stage: init-network
|`->no cache found #16.01000s +00.00100s
|`->no network data found from DataSourceOpenStack #16.01700s +00.02600s
|`->found network data from DataSourceNone #16.04300s +00.00100s
|`->setting up datasource #16.09000s +00.00000s
|`->reading and applying user-data #16.10000s +00.00200s
|`->reading and applying vendor-data #16.10200s +00.00000s
|`->activating datasource #16.12100s +00.00100s
|`->config-migrator ran successfully #16.17900s +00.00100s
|`->config-seed_random ran successfully #16.18000s +00.00100s
|`->config-bootcmd ran successfully #16.18200s +00.00000s
|`->config-write-files ran successfully #16.18200s +00.00100s
|`->config-growpart ran successfully #16.18300s +00.46100s
|`->config-resizefs ran successfully #16.64500s +01.33400s
|`->config-disk_setup ran successfully #17.98100s +00.00300s
|`->config-mounts ran successfully #17.98500s +00.00400s
|`->config-set_hostname ran successfully #17.99000s +00.09800s
|`->config-update_hostname ran successfully #18.08900s +00.01000s
|`->config-update_etc_hosts ran successfully #18.10000s +00.00100s
|`->config-rsyslog ran successfully #18.10100s +00.00200s
|`->config-users-groups ran successfully #18.10400s +00.00200s
|`->config-ssh ran successfully #18.10700s +00.61400s
Finished stage: (init-network) 02.73600 seconds
Starting stage: modules-config
|`->config-locale ran successfully #35.00200s +00.00400s
|`->config-set-passwords ran successfully #35.00600s +00.00100s
|`->config-zypper-add-repo ran successfully #35.00700s +00.00200s
|`->config-ntp ran successfully #35.01000s +00.00100s
|`->config-timezone ran successfully #35.01100s +00.00200s
|`->config-disable-ec2-metadata ran successfully #35.01300s +00.00100s
|`->config-runcmd ran successfully #35.01800s +00.00200s
Finished stage: (modules-config) 00.05100 seconds
Starting stage: modules-final
|`->config-package-update-upgrade-install ran successfully #35.87400s +00.00000s
|`->config-puppet ran successfully #35.87500s +00.00000s
|`->config-chef ran successfully #35.87600s +00.00000s
|`->config-mcollective ran successfully #35.87600s +00.00100s
|`->config-salt-minion ran successfully #35.87700s +00.00100s
|`->config-rightscale_userdata ran successfully #35.87800s +00.00100s
|`->config-scripts-vendor ran successfully #35.87900s +00.00500s
|`->config-scripts-per-once ran successfully #35.88400s +00.00100s
|`->config-scripts-per-boot ran successfully #35.88500s +00.00000s
|`->config-scripts-per-instance ran successfully #35.88500s +00.00100s
|`->config-scripts-user ran successfully #35.88600s +00.00100s
|`->config-ssh-authkey-fingerprints ran successfully #35.88700s +00.00100s
|`->config-keys-to-console ran successfully #35.88800s +00.09000s
|`->config-phone-home ran successfully #35.97900s +00.00100s
|`->config-final-message ran successfully #35.98000s +00.00600s
|`->config-power-state-change ran successfully #35.98700s +00.00100s
Finished stage: (modules-final) 00.13600 seconds
Total Time: 18.23500 seconds
1 boot records analyzed
Update 3
Apparently, when one does not update with zypper up, cloud-init behaves well and finds the user data. Hence, I will not update the image in provisioning. However, once provisioned it makes sense to update.
In the end of your provisioning you should stop cloud-init and wipe the state. Otherwise when the image is launched cloud-init think it already executed the first launch.
systemctl stop cloud-init
rm -rf /var/lib/cloud/
i have sshd into my OpenShift Drupal install with the intent of changing my Drupal admin password ..however the drush tool does not seem to be installed
[drupal-.rhcloud.com 56f94fb97628e12ab700005f]> drush --help
bash: drush: command not found
[drupal-.rhcloud.com 56f94fb97628e12ab700005f]>
i am using :
Drupal 7
is there something that needs doing to get that drush addition?
it seams openshift drush is not working for every bodies.its happened because of using old PHP version, which is not working by new composer, SO you need to make one DIY app in openshift and install manually drush and new version of php (php >=5.5.0 ).
Drush installing in Openshift RHC
So you could install drush manually by this codes:
mkdir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer
curl -ss https://getcomposer.org/installer | php -- --install-dir=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer
cd /tmp
rm -rf tt
mkdir tt
cd tt
#wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
wget https://github.com/drush-ops/drush/archive/master.zip && unzip master.zip
rm master.zip
mv * drush
chmod u+x drush/drush
#tar xzf drush-7.x-5.9.tar.gz && rm drush-7.x-5.9.tar.gz && cd drush && mv drush drush_my
mkdir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/
mkdir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush
mv /tmp/tt/drush/* ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush && cd ../..
rm -rf tt
export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH
cd ~/app-root/runtime/repo/.openshift/action_hooks
echo "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH
#export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer:$PATH" >> ~/app-root/runtime/repo/.openshift/action_hooks/start
chmod 755 start
echo "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH
export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer:$PATH
alias drush='${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush/drush'
alias drush='/opt/rh/php54/root/usr/bin/php ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush/drush.php'" >> ~/app-root/data/.bash_profile
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush
php -r "readfile('https://getcomposer.org/installer');" | php
mv composer.phar composer.phar0
php composer.phar0 install
php composer.phar0 update
#composer config --global bin-dir /usr/local/bin
#composer config --global bin-dir /opt/rh/php54/root/usr/bin
composer config --global vendor-dir ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer
php composer install
php ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/composer/composer.phar --no-interaction --no-ansi --no-scripts --optimize-autoloader --working-dir=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush install
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush
# Drush settings
cp drush.php drush.php0
echo "\$options['uri'] = \$_ENV['OPENSHIFT_APP_DNS'];
\$options['root'] = \$_ENV['OPENSHIFT_REPO_DIR'].'php';" >> drush.php
if [[ -f ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush/drush.php ]]; then
echo "$repo_top = getcwd().'/..';
$options['config'] = $repo_top . '/drush/drushrc.php'; "
else
echo "<?php
$repo_top = getcwd().'/..';
$options['config'] = $repo_top . '/drush/drushrc.php'; " >> drush.php
fi
cat << EOF >>drushrc.php
<?php
ini_set('memory_limit', '256M');
if (array_key_exists('OPENSHIFT_APP_NAME', \$_SERVER)) {
\$src = \$_SERVER;
} else {
\$src = \$_ENV;
}
\$options['uri'] =\$src['OPENSHIFT_APP_DNS'];
\$options['root'] =\$src['OPENSHIFT_REPO_DIR'].'php';
\$options['db-url']=\$src['OPENSHIFT_MYSQL_DB_URL'].\$src['OPENSHIFT_APP_DNS'];
\$options['backup-dir'] = '/tmp';
?>
EOF
echo " \$options['backup-dir'] = '/tmp';">> drushrc.php
#nano drush.php
drush status
#install mysql
: <<'end_long_comment'
#
cd /tmp
wget http://wiki.diahosting.com/down/lnmp/mysql-5.1.46.tar.gz
nohup sh -c "./configure --prefix=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables &&
make && make install"> $OPENSHIFT_LOG_DIR/mysql_install.log /dev/null 2>&1 & tail -f $OPENSHIFT_LOG_DIR/mysql_install.log
chown -R mysql:mysql ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql
cp support-files/my-medium.cnf /etc/my.cnf
sed -i 's#\[mysqld\]#\[mysqld\]\nbasedir=/usr/local/mysql\ndatadir=/var/lib/mysql\n#' /etc/my.cnf
sed -i 's#log-bin=mysql-bin#\#log-bin=mysql-bin#' /etc/my.cnf
sed -i 's#binlog_format=mixed#\#binlog_format=mixed#' /etc/my.cnf
${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysql_install_db --basedir=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql --datadir=/var/lib/mysql --user=mysql
cp ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start
${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysqladmin -u root password $myrootpwd
chkconfig mysqld on
#ln -s ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/myisamchk /usr/bin/
#ln -s ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysql /usr/bin/
#ln -s ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/mysql/bin/mysqldump /usr/bin/
end_long_comment
cd
export pass=$OPENSHIFT_MYSQL_DB_PASSWORD
export user=$OPENSHIFT_MYSQL_DB_USERNAME
mysql -u $OPENSHIFT_MYSQL_DB_USERNAME
DROP DATABASE drupal2;
CREATE DATABASE drupal2;
#CREATE USER druser#localhost;
#CREATE USER druser2#$OPENSHIFT_MYSQL_DB_HOST;
CREATE USER 'druser'#'$OPENSHIFT_MYSQL_DB_HOST' IDENTIFIED BY 'druser';
#CREATE USER 'juddi'#'$OPENSHIFT_MYSQL_DB_HOST' IDENTIFIED BY 'juddi';
#SET PASSWORD FOR druser#localhost= PASSWORD("password");
SET PASSWORD FOR 'druser'#$OPENSHIFT_MYSQL_DB_HOST= PASSWORD("password");
#GRANT ALL PRIVILEGES ON drupal2.* TO druser#localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON drupal2.* TO $user#$OPENSHIFT_MYSQL_DB_HOST IDENTIFIED BY $pass;
#GRANT ALL PRIVILEGES ON drupal.* TO $OPENSHIFT_MYSQL_DB_USERNAME#$OPENSHIFT_MYSQL_DB_HOST IDENTIFIED BY $OPENSHIFT_MYSQL_DB_PASSWORD;
FLUSH PRIVILEGES;
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php
chmod 755 . -R
rm -rf *
if [[ 1=2 ]];then
drush dl openpublic #--drupal-project-rename=folder_name
mv open*/* ./
cd pro*/openpu*
drush make --prepare-install build-openpublic.make openpublic
rm -rf ~/app-root/data/sites/default/settings.php
fi
echo " \$options['backup-dir'] = '/tmp';">> ~/.drush/drushrc.php
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php
nohup sh -c "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH && drush dl openpublic"> $OPENSHIFT_LOG_DIR/drush_site_install_1_1.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/drush_site_install_1_1.log
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php && mv */* './' && cd pro*/openpu*
nohup sh -c "export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/drush:$PATH && drush make --prepare-install build-openpublic.make openpublic &&\
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php &&\
drush site-install openpublic --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/drupal2 --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --yes"> $OPENSHIFT_LOG_DIR/drush_site_install_1_2.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/drush_site_install_1_2.log
#drush site-install weebpal --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --account-mail='ss3#elec-lab.tk' --site-mail='ss3#elec-lab.tk' --yes
#nohup sh -c "drush site-install themebrain_profile --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/drupal2 --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --account-mail='ss3#elec-lab.tk' --site-mail='ss3#elec-lab.tk' --yes ">$OPENSHIFT_LOG_DIR/drush_site_install_1_2.log /dev/null 2>&1 & tail -f $OPENSHIFT_LOG_DIR/drush_site_install_1_2.log
#drush site-install opendeals --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --account-mail=ss3#elec-lab.tk --yes
#drush site-install openpublic --db-url=mysql://druser:password#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/drupal2 --site-name=${OPENSHIFT_APP_NAME} --account-name='ss' --account-pass='ss' --yes
#drush site-install openpublic --site-name=${OPENSHIFT_APP_NAME} --account-pass=$admin_pwd --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --yes
#mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -h $OPENSHIFT_MYSQL_DB_HOST drupal <
########DONE ##################
echo " \$options['backup-dir'] = '/tmp';">> ~/.drush/drushrc.php
### drush backup database###
drush sql-dump > /tmp/database-backup.sql
### drush restore database###
mysqldump -u $OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PORT $OPENSHIFT_APP_NAME < database-backup.sql
mysqldump -u USERNAME -p'PASSWORD' DATABASENAME > /path/to/backup_dir/database-backup.sql
drush sql-cli < ~/my-sql-dump-file-name.sql
drush bam-backup
####################################
nohup sh -c " wget -P ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php --mirror --user=u220290147 --password=ss123456 ftp://93.188.160.83:21/"> $OPENSHIFT_LOG_DIR/python_modules_install_1_1.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/python_modules_install_1_1.log
cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/repo/php/*
nohup sh -c "zip -r elec-lab.zip . "> $OPENSHIFT_LOG_DIR/zip.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/zip.log
/tmp/tmp/tb/sites/all/modules
~/app-root/data/sites/all/modules
mkdir ~/app-root/data/sites/all/libraries
mv -n /tmp/tmp/tb/sites/all/libraries/* ~/app-root/data/sites/all/libraries
mkdir ~/app-root/data/sites/all/themes
mv -n /tmp/tmp/tb/sites/all/themes/* ~/app-root/data/sites/all/themes
mv -n /tmp/tmp/tb/sites/all/* ~/app-root/data/sites/all/
mv -n /tmp/tmp/tb/sites/* ~/app-root/data/sites/
mv -n /tmp/tmp/tb/sites/all/modules/* ~/app-root/data/sites/all/modules
mkdir ~/app-root/data/downloads/drupal-7.34/profiles/themebrain_profile
mv -n /tmp/tmp/tb/profiles/themebrain_profile/* ~/app-root/data/downloads/drupal-7.34/profiles/themebrain_profile
mv ~/app-root/runtime/repo/.openshift/install_profiles/standard ~/app-root/runtime/repo/.openshift/install_profiles/standard1
mkdir ~/app-root/runtime/repo/.openshift/install_profiles/standard
mv -n /tmp/op/openpublic-7.x-1.x-dev/profiles/openpublic/* ~/app-root/runtime/repo/.openshift/install_profiles/standard
chmod 755 ~/app-root/data/sites/default/settings.php
rm -rf ~/app-root/data/sites/default/settings.php
chmod 755 ~/app-root/runtime/repo/.openshift/action_hooks/deploy
nohup sh -c "./app-root/runtime/repo/.openshift/action_hooks/deploy "> $OPENSHIFT_LOG_DIR/deploy.log /dev/null 2>&1 & tail -f $OPENSHIFT_LOG_DIR/deploy.log
#tail -f $OPENSHIFT_LOG_DIR/deploy.log
#nohup sh -c "wget http://dl1.sarzamindownload.com/sdlftpuser/92/07/10/Android.Bootcamp_Part2.rar "> $OPENSHIFT_LOG_DIR/zip2.log /dev/null 2>&1 &
#tail -f $OPENSHIFT_LOG_DIR/zip2.log
rm drush_download.py
cat <<'EOF' >> drush_download.py
import subprocess
import ast
st1='"Nodeblock, Follow, Securepages, Addthis, Twitter_pull, Comment_notify, Context_field, Entity_autocomplete, Views_boxes, Delta, Delta_ui, Context_condition_admin_theme, Context_breadcrumb_current_page, Context_bool_field, Nodeconnect, Openpublic_splash, Phase2_profile, Openpublic_breaking_news, Openpublic_comments, Openpublic_base_fields, Openpublic_defaults, Openpublic_home_page_feature, Openpublic_most_popular, Openpublic_person, Openpublic_person_leadership, Openpublic_site_page, Openpublic_webform, Openpublic_editors_choice, Openpublic_captcha, Openpublic_media_room, Openpublic_menu, Openpublic_menu_utility, Openpublic_menu_footer, Openpublic_pages, Openpublic_accessibility, Openpublic_filters, Openpublic_comments_default, Openpublic_webform_defaults"'
st1='"Addthis, Openpublic_splash, Phase2_profile, Openpublic_breaking_news, Openpublic_comments, Openpublic_base_fields, Openpublic_defaults, Openpublic_home_page_feature, Openpublic_most_popular, Openpublic_person, Openpublic_person_leadership, Openpublic_site_page, Openpublic_webform, Openpublic_editors_choice, Openpublic_captcha, Openpublic_media_room, Openpublic_menu, Openpublic_menu_utility, Openpublic_menu_footer, Openpublic_pages, Openpublic_accessibility, Openpublic_filters, Openpublic_comments_default, Openpublic_webform_defaults"'
st1=st1.lower()
st1=st1.replace(',',"','").replace('"',"'")
st2='"['+st1+']"';st2=st2.replace('"','')
ss=ast.literal_eval(st2)
#print ss
print st
for module in ss:
try:
st='drush dl '+module+' -Y ';print st
awk_sort = subprocess.Popen( [st ], stdin= subprocess.PIPE, stdout= subprocess.PIPE,shell=True)
awk_sort.wait()
output = awk_sort.communicate()[0]
print output.rstrip()
except:
print 'module '+module+' could not bin installed !!!'
#print "END"
EOF
#python drush_download.py
drush site-install standard --site-name=${OPENSHIFT_APP_NAME} --account-pass=$admin_pwd --db-url=mysql://$OPENSHIFT_MYSQL_DB_USERNAME:$OPENSHIFT_MYSQL_DB_PASSWORD#$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME --yes
nohup sh -c "python drush_download.py"> $OPENSHIFT_LOG_DIR/drush_download.log /dev/null 2>&1 &
tail -f $OPENSHIFT_LOG_DIR/drush_download.log
#nohup sh -c "zip -rT9 ferdowsi-elec-labs_tk.zip '${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/tmp/.'"> $OPENSHIFT_LOG_DIR/python_ftp_sync_download.log /dev/null 2>&1 &
#nohup sh -c "cd ${OPENSHIFT_HOMEDIR}/app-root/runtime/srv/tmp/ && zip -rT9 ferdowsi-elec-labs_tk.zip ."> $OPENSHIFT_LOG_DIR/python_ftp_sync_download.log /dev/null 2>&1 &
#tail -f $OPENSHIFT_LOG_DIR/python_ftp_sync_download.log
I configured WP_UnitTestCase and the wp_cli and PHPUnit with composer in PHPStorm. I had an issue where it couldn’t find/use my WP DB username and password to create the DB so I created it manually in the terminal. (was this a mistake?) install-wp-tests.sh the installed, I was able to run some test did a bit of development and then shutdown my machine.
The next day, I started up my machine and attempted to continue where I left off. However PHPunit (should I be calling this WP_UnitTestCase instead?) Failed to run with the following errors.
Warning: require_once(/tmp/wordpress-tests-lib/includes/functions.php): failed to >open stream: No such file or directory in /thefullpathtowordpressprojectd/wp->content/plugins/myplugin/tests/bootstrap.php on line 8
Well /tmp/wordpress-tests-lib/ doesn’t exist
So I look into the install-wp-tests.sh and its installing itself to a tmp directory…okay?! (So ok I did notice that phpunit said Installing when I ran my tests the night before… so it reinstalls itself for every test!?)
Then I re-run ‘install-wp-tests.sh’, it fails when attempting to create the ‘wordpress-tests’ db since it already exist but I can now run tests again.
My question is even if the scaffolding/ WP_UnitTestCase reinstalls itself every time I run phpunit in the directory of my plugin folder where my phpunit.xml is. What do I have to change in the ‘install-wp-tests.sh’ or phpunit.xml so I don't have to manually reinstall for an existing project, how to clear the require_once error for the tmp empty directory?
Should I have to reinstall it everytime I reopen my project?
my install-we-test.sh is unchanged, but here it is:
#!/usr/bin/env bash
if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
exit 1
fi
DB_NAME=$1
DB_USER=$2
DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
set -ex
download() {
if [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
fi
}
install_wp() {
if [ -d $WP_CORE_DIR ]; then
return;
fi
mkdir -p $WP_CORE_DIR
if [ $WP_VERSION == 'latest' ]; then
local ARCHIVE_NAME='latest'
else
local ARCHIVE_NAME="wordpress-$WP_VERSION"
fi
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
}
install_test_suite() {
# portable in-place argument for both GNU sed and Mac OSX sed
if [[ $(uname -s) == 'Darwin' ]]; then
local ioption='-i .bak'
else
local ioption='-i'
fi
# set up testing suite if it doesn't yet exist
if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite
mkdir -p $WP_TESTS_DIR
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/ $WP_TESTS_DIR/includes
fi
cd $WP_TESTS_DIR
if [ ! -f wp-tests-config.php ]; then
download https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
fi
}
install_db() {
# parse DB_HOST for port or socket references
local PARTS=(${DB_HOST//\:/ })
local DB_HOSTNAME=${PARTS[0]};
local DB_SOCK_OR_PORT=${PARTS[1]};
local EXTRA=""
if ! [ -z $DB_HOSTNAME ] ; then
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
EXTRA=" --socket=$DB_SOCK_OR_PORT"
elif ! [ -z $DB_HOSTNAME ] ; then
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
fi
fi
# create database
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}
install_wp
install_test_suite
install_db
and my phpunit.xml
<phpunit
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite>
<directory prefix="test-" suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
I can do a normal deploy using the below command
curl -i -X PUT -u $artifactoryUser:$artifactoryPassword -T /path/to/file/file.zip http://localhost/artifactory/simple/repo/groupId/artifactId/version/file.zip
However, this will not resolve or update maven layout on the artifact. Is there a way I can upload without using the artifactory-maven plugin?
I found a solution to this question I had posted.
Syntax Used:
curl -i -X PUT -K $CURLPWD "http://localhost/artifactory/$REPO/$groupId/$artifactId/$versionId/$artifactId-$versionId.$fileExt"
Ended up writing a script so that md5 & sha1 values are uploaded with the file, or else, I had to go in Artifactory and fix it manually.
#!/bin/bash
usage() {
echo "Please check the Usage of the Script, there were no enough parameters supplied."
echo "Usage: ArtifactoryUpload.sh localFilePath Repo GroupID ArtifactID VersionID"
exit 1
}
if [ -z "$5" ]; then
usage
fi
localFilePath="$1"
REPO="$2"
groupId="$3"
artifactId="$4"
versionId="$5"
ARTIFAC=http://localhost/artifactory
if [ ! -f "$localFilePath" ]; then
echo "ERROR: local file $localFilePath does not exists!"
exit 1
fi
which md5sum || exit $?
which sha1sum || exit $?
md5Value="`md5sum "$localFilePath"`"
md5Value="${md5Value:0:32}"
sha1Value="`sha1sum "$localFilePath"`"
sha1Value="${sha1Value:0:40}"
fileName="`basename "$localFilePath"`"
fileExt="${fileName##*.}"
echo $md5Value $sha1Value $localFilePath
echo "INFO: Uploading $localFilePath to $targetFolder/$fileName"
curl -i -X PUT -K $CURLPWD \
-H "X-Checksum-Md5: $md5Value" \
-H "X-Checksum-Sha1: $sha1Value" \
-T "$localFilePath" \
"$ARTIFAC/$REPO/$groupId/$artifactId/$versionId/$artifactId-$versionId.$fileExt"