How to delete all files with lftp except for cgi-bin and .ftpquota - gitlab-ci

I'm setting up a new ci/cd pipeline on gitlab. For the deployment I have to run npm run build and then copy the dist/ folder to the webserver via ftp (with lftp). To ensure a clean deployment the script should remove all files except the folder cgi-bin and the file .ftpquota on the webserver first and then copy the files.
I've researched through the web and haven't found a suitable solution. With the flag --delete, lftp deletes all files.
Thats my script so far:
- lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD $HOST; mirror -Rnev dist/ ./ --ignore-time --delete --parallel=10 --exclude-glob .git* --exclude .git/"
My current script removes all files, but I want it to remove everything except the cgi-bin folder and the .ftpquota file.

As seen in unix.stackexchange.com you should add the -x option:
Please check it

Related

pocketbase: command not found

I am trying to set up a pocketbase on a Debian server.
on the server I created a dir called pb and scp over the pocketbase file which I downloaded from https://pocketbase.io/docs/
I downloaded all three linux packages pocketbase_0.10.2_linux_amd64.zip , pocketbase_0.10.2_linux_arm64.zip and pocketbase_0.10.2_linux_armv7.zip
I download the file, unzip it and then move the pocketbase file over to the server.
Note, Ive downloaded these onto a windows machine and then SCP pocketbase file over to my server.
When I run pocketbase serve I get the error command not found.
I can't find a good solution to this issue.
Execute it as instructed by pocketbase's documentation if you are within the same directory as the bin file:
./pocketbase serve
If you want to run it as pocketbase serve alone you will need to move the bin file under /usr/bin or ideally /usr/local/bin which should be under your system's $PATH variable.
https://pocketbase.io/docs/
Run ./pocketbase --help or ./pocketbase [command] --help for more assistance.

code deployment via zipped file in jenkins

I am new to Jenkins and still taking baby steps to learn it. What I have could be very simple to some people but I couldn't find a straightforward way to do it. I simply want to take source code in a zipped file format and do the following:
copy to remote server in a certain directoy
delete the old code
unzip the new code
delete the zipped file
finally start apache web server
I have installed plugins like ssh2, ssh-copy, remote commands, etc but still cannot achieve what I am looking in to do. Any help would greatly appreciated it.
I have a Spring project and build it to get a .war file by Jenkins.
The following shell commands show how to copy the .war to a remote server and to run it on Tomcat.
remote_host=192.168.1.2
tomcat_home=/x/y
# stop web server
ssh root#${remote_host} "sh /root/stop.sh" || echo "something wrong ignored!"
# copy to remote server in a certain directoy
scp $WORKSPACE/build/libs/myapp-test.war root#${remote_host}:$tomcat_home/webapps/myapp.war
# delete the old code
ssh root#${remote_host} "rm -rf $tomcat_home/webapps/*"
# unzip the new code
ssh root#${remote_host} "unzip -o $tomcat_home/webapps/myapp.war -d $tomcat_home/webapps/myapp"
# delete the zipped file
ssh root#${remote_host} "rm -rf $tomcat_home/webapps/myapp.war"
# finally start apache web server
ssh root#${remote_host} "sh $tomcat_home/bin/startup.sh"
In my case, I put the commands in a Jenkins job and at the section: Build -- Execute shell -- Command

Is it possible to use AWS Beanstalk's .ebextensions config to install mod_pagespeed Apache module?

I'm using AWS Beanstalk for my Django/Python application, and I would like to use Google's mod_pagespeed module. Is it possible to install and run mod_pagespeed using the .ebextensions/.config file?
Download the package
Add the rpm into your ebextensions directory
create a .config file in the .ebextensions directory
add commands to the config file like this:
container_commands:
01-command:
command: rm -rf /pagespeed/ebextensions
02-command:
command: mkdir -p /pagespeed/ebextensions
03-command:
command: cp -R .ebextensions/* /pagespeed/ebextensions/
04-command:
command: rpm -U /pagespeed/ebextensions/mod-pagespeed.rpm
Ensure the commands are indented as shown, with no tabs, otherwise it wont work.
swap "mod-pagespeed.rpm" for whatever the actual rpm file name is.
Ok so I want to add Charlie Smith's answer. I would suggest you make sure you have the following things turned on.
mod_deflate - You probably want to Gzip your html, css, xml, and javascript.
Enable the rewrite domains filter in your Apache.conf if you use CDN (ex. AWS CloudFront)
Set a short cache-control for images and css so pagespeed will be able to extend the cache when you turn on the extend_cache filter.
I also like the rewrite_javascript, dns_prefetch, collapse_whitespace, and combine_javascript filters.
Here are the GitHub Gists that show you how its done.
The apache conf file
The Beanstalk container_commands (they are mostly the same as Charlie's)
Thanks guys! I got it working great following your answer #man2xxl.
You don't have to mess with the /pagespeed/extensions directory though, the beanstalk .ebextensions config can simply be:
packages:
yum:
at: []
10_setup_apache_for_mod_pagespeed:
command: "cp enable_mod_pagespeed.conf /etc/httpd/conf.d"
20_install_mod_pagespeed:
command: rpm -U -iv --replacepkgs mod-pagespeed-*.rpm
30_clear_mod_pagespeed_cache:
command: touch /var/cache/mod_pagespeed/cache.flush
You can install packages by URL. So you don't have to download and distribute the RPM. Something like this works:
packages:
rpm:
pagespeed: https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
files:
"/etc/httpd/conf.d/zzzz-pagespeed-options.conf":
mode: "00644"
owner: root
group: root
encoding: plain
content: |
# put your pagespeed configuration here
Note that I titled the file zzzz-pagespeed-options.conf so that the httpd server will load it last.
Another advantage of this is you really don't need include any commands whatsoever or worry about copying files over
and maintaining the files in your .ebextensions folder. You just update the files entry in the .config file.

Unable to move file to packages directory-socialengine addons core plugin

While uploading the socialengine addon's core plugin (module-seaocore-4.2.9p1.tar) through package manager, I am getting an error
Unable to move file to packages directory.
Please set chmod 0777 on the temporary/package/archives directory.
But, if we try to upload any other plugin, it will get extracted in the normal way.
I have checked the file permission and it is already 777.
Uploading the tar to temporary/package/packages and extracting it into a folder (final path: temporary/package/packages/module-seaocore-4.2.9p1) does not always work for me.
However, the following steps do seem to work if you have chmod 777 permission set on both your temporary/package/packages and temporary/packages/archives directories:
Try the installation and let it fail with the above error message
Upload the tar to temporary/package/archives
Go back to the Manage Packages & Plugins screen in the SE admin panel, and then click Install New Packages
It will find the tar in temporary/package/archives, process the extraction to temporary/package/packages, and let you install
I've replicated this a number of times now, and it seems to work.
I fixed this issue by uplading the tar file to temporary/package/packages and extracted it to the folder with the name module-seaocore-4.2.9p1.
Then deleted the tar file and went to package manager and installed the plugin.
I got the solution for this,
Extract the ".tar file" and then open the "applications" folder and you will find 3 folder "languages, modules, packages" copy all the files and folders you find in these folders and paste them to the respective "application" folder in your working directory,
remember
After copying them again give the chmod - R 0777 permission to you package directory of working folder.
sudo chmod -R 0777 packages/
Now you can find an option to install the plugin in "Manage Plugin" section in the admin pannel.

Putty ssh commands zip all the files within this folder then download

oh so i cd into my folder
ls
cgi-bin wp-comments-post.php wp-mail.php
googlec3erferfer228fc075b.html wp-commentsrss2.php wp-pass.php
index.php wp-config-sample.php wp-rdf.php
license.txt wp-config.php wp-register.php
php.ini wp-content wp-rss.php
readme.html wp-cron.php wp-rss2.php
wp-activate.php wp-feed.php wp-settings.php
wp-admin wp-includes wp-signup.php
wp-app.php wp-links-opml.php wp-trackback.php
wp-atom.php wp-load.php xmlrpc.php
wp-blog-header.php wp-login.php
(uiserver):u45567318:~/wsb454434801 >
What i want to do is zip all the files within this folder then download it to my computer i am really new to ssh and this is a clients website but really want to start to use command line for speed, i have been looking a this reference http://ss64.com/bash/ to find the right commands but would really like some help from somebody please??
Thanks
cd path/to/folder/foldername
zip -r foldername.zip foldername * [use * if it has any sub directory]
Please try this code, it will solve your problem.
If you are in directory itself then
zip -r zipfilename.zip *
Go to folder path using cd command
zip -r foldername.zip foldername
Ex : zip -r test-bkupname.zip test
Here test is the folder name.
tar zcvf ../my_directory.tar.gz .
will create my_directory.tar.gz file.
scp ../my_directory.tar.gz username#your-ip:/path/to/place/file
will transfer file to your computer.
Looks like this is the webroot directory.
Why not zip the directory above (httpdocs / html / whatever) and then move this into the website space, and download from there?
i.e. go into the directory above the web root. For example, if your web root is /var/www/html/ go into /var/www/ and run the following commands:
zip -r allwebfiles.zip html
mv allwebfiles.zip /html/allwebfiles.zip
Then in your web browser go to http://mydomain.com/allwebfiles.zip and just download that file.
When extracting, you'd just need to either extract into /var/www/ OR extract into webroot and move all files up one level.
Use the following Ssh command to download multiple files at one time
mget ./*